[Haskell-beginners] Difference between Monad composition and transformation

Dennis Raddle dennis.raddle at gmail.com
Sat Aug 25 12:14:02 CEST 2012

I'm not exactly a Haskell beginner but haven't grasped much of it yet. I
have a feeling the answer to your question has something to do with the
fact that the monad transformer library provides instances that allow the
use of, for example, "get" and "put" in any transformed monad that has a
StateT somewhere in it. Or throwError in anything that has an ErrorT in it.
In other words, you don't need to lift everything into the right level.

Okay, that's a crude way of putting it, but someone will probably come
along and clarify.

On Sat, Aug 25, 2012 at 1:15 AM, Song Zhang <vxanica at gmail.com> wrote:

> When I use a State Monad transformer to combine with a Writer Monad
> StateT s (Writer w) a. is it different from composition of State Monad and
> Writer Monad. It is State s (Writer w a) ?
> StateT is defined as (s -> m (a, s)), so StateT s (Writer w) a can be
> regarded as (s -> Writer w a) , which is (s -> ((a,w),s)
> and on the other hand State s (Writer w a) is (s -> ((a,w),s). I suppose
> the are similar and if so, what is the point we still get Monad
> transformers? Thanks
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20120825/5d31f39b/attachment.htm>

More information about the Beginners mailing list