
5 Dec
2008
5 Dec
'08
10:54 a.m.
On Fri, Dec 05, 2008 at 04:35:51PM +0100, Martijn van Steenbergen wrote:
How do I implement the following?
instance Applicative f => Applicative (StateT s f)
The implementation of pure is trivial, but I can't figure out an implementation for <*>. Is it possible at all, or do I need to require f to be a monad?
Yes, because you need part of the value generated by the first computation, namely the state (inside the f), to construct the second one. You can do that in a Monad, but not in an Applicative.