[Haskell-cafe] instance Applicative f => Applicative (StateT s f)
ross at soi.city.ac.uk
Fri Dec 5 10:54:03 EST 2008
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.
More information about the Haskell-Cafe