[Haskell-cafe] About the Monad Transformers

.shawn stircrazynemo at hotmail.com
Wed Jun 17 11:54:16 EDT 2009

On page 141 of "Yet another Haskell Tutorial" (9.7 Monad Transformers)

mapTreeM action (Leaf a) = do
    lift (putStrLn ("Leaf" ++ show a))
    b <- action a
    return (Leaf b)
mapTreeM :: (MonadTrans t, Monad (t IO), Show a) => (a -> t IO a1) -> Tree a -> t IO (Tree a1)

Why does the type signature of mapTreeM look like this?
And what does it mean by "The lift tell us that we're going to be executing a command in an enclosed monad. In this case the enclosed monad is IO"? Why does the author put lift here? How does the lift work?

I have no idea about the explanation in the book...is there anyone can give me some hints about this?
Thank you in advance!

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090617/c53d3fe5/attachment.html

More information about the Haskell-Cafe mailing list