[Haskell-cafe] Question on nested State monads.
lucas di cioccio
lucas.dicioccio at gmail.com
Sun Dec 29 08:25:58 UTC 2013
> If I want to use a second, nested State monad inside another State monad,
> must I thread the outer monad’s state through the processing of the inner
> one, even if the inner one falls out of scope before I return from the
> processing body of the outer one?
In short: yes you can nest StateT and to access the "inner parts" you need
to lift the get/put/modify functions. The Real-World Haskell book has an
example for stacking monad transformers of a same TypeClass (cf.
explicit lifting is necessary".)
The first time, it's best to convince yourself by writing down the types of
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe