Looking at the docs for Control.Applicative
, I notice that they have instance declarations for certain monads (e.g. IO
, Maybe
and notably ST
), but there are no instances for MTL monads such as State
and RWS
. Instead it looks like there's a general-purpose WrappedMonad
type defined, which I'm guessing is to cover all other cases.
So here are my questions:
Why aren't there
Applicative
instances for MTL monads? The best answer I've been able to find on my own so far is a three year old post, where somebody implemented these instances and was summarily ignored.What's the deal with
WrappedMonad
? I found a post on Reddit that explains it briefly, but I think I'm confused about how to use it.
Ultimately I'd like to be able to use State
in an applicative style (as was recommended to me), but if I have to litter my code with WrappedMonad
data constructors then it doesn't seem like a win. I could also ignore WrappedMonad
entirely, and define the Applicative
instance myself the same way that was done for IO
, ST
and so on: in terms of return
and ap
... But that seems goofy as well.