@@ -19,6 +19,13 @@ instance Functor f => Functor (StateT s f) where
1919 mapFst : (a -> x) -> (a, b) -> (x, b)
2020 mapFst fn (a, b) = (fn a, b)
2121
22+instance Monad f => Applicative (StateT s f) where
23+ pure x = ST (\st => pure (x, st))
24+
25+ (ST f) <$> (ST a) = ST (\st => do (g, r) <- f st
26+ (b, t) <- a r
27+ return (g b, t))
28+
2229instance Monad m => Monad (StateT s m) where
2330 return x = ST (\st => return (x, st))
2431