testsuite: fix T1735_Help/State.hs build failure (AMP)
[ghc.git] / testsuite / tests / typecheck / should_run / T1735_Help / State.hs
1
2 module T1735_Help.State where
3
4 import Control.Monad (ap, liftM)
5
6
7 newtype StateT s m a = StateT { runStateT :: s -> m (a,s) }
8
9 instance Monad m => Monad (StateT s m) where
10 return a = StateT $ \s -> return (a, s)
11 m >>= k = StateT $ \s -> do
12 ~(a, s') <- runStateT m s
13 runStateT (k a) s'
14 fail str = StateT $ \_ -> fail str
15
16 instance Monad m => Functor (StateT s m) where
17 fmap = liftM
18
19 instance Monad m => Applicative (StateT s m) where
20 pure = return
21 (<*>) = ap
22
23 get :: Monad m => StateT s m s
24 get = StateT $ \s -> return (s, s)
25
26 put :: Monad m => s -> StateT s m ()
27 put s = StateT $ \_ -> return ((), s)
28