Mon Oct 24 22:30:34 EDT 2011
1. How can it be?
Following . Dropping wrappers for clarity, we have:
StateT s m a = s -> m (s, a)
which is a state monad parameterized by a monad. If m = Id we
get the ordinary state monad:
s -> (s, a)
if two of these are chained we get
StateT t (StateT s Id) a =
t -> (StateT s Id) (t, a)
t -> s -> (s, (t, a))
So the deal is: a monad transformer is parameterized by a monad in
such a way that simply substituting a different type will give a
2. How can it be used?
Each transformer needs to define a method that provides access to the
lift :: (MonadTrans t, Monad m) => m a -> t m a
It looks like the MTL has some type classes defined that prevent the
use of multiple lift applications to dig into the onion.