[Haskell-cafe] Still stacking monad transformers
Miguel Mitrofanov
miguelimo38 at yandex.ru
Sun Oct 12 13:25:10 EDT 2008
On 12 Oct 2008, at 21:08, Andrew Coppin wrote:
> I found that by using the brief and easily memorable construction
> "runIdentity $ runListT $ runStateT foo state" I can get at the
> result set for each action, and combine them. But nothing in hell
> seems to transform this from [((), MyState)] back into MyMonad ().
Well, State monad (and StateT transformer) doesn't work with STATE,
they work with STATE CHANGES. So, instead of [((), MyState], you
should have something like (MyState -> [((), MyState)]). And that can
be transformed to MyMonad () quite easily:
Prelude Control.Monad.State Control.Monad.List
Control.Monad.Identity> :t \f -> StateT $ ListT . Identity . f
\f -> StateT $ ListT . Identity . f :: (s -> [(a, s)]) -> StateT s
(ListT Identity) a
More information about the Haskell-Cafe
mailing list