On 17 Jun 2009, at 19:54, .shawn wrote:

Why does the type signature of mapTreeM look like this?

Why not? I can't think of any other possibility.

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"?

Wild guess: I think they mean exactly what they said. Literally.

Why does the author put lift here?

Because he wanted to work in a more general setting than just IO monad. He needed IO, of course, because of "putStrLn", but he wanted to give the user of this function an opportunity to do something besides just IO.

How does the lift work?

"lift" is defined in the "MonadTrans" type class, so it works differently depending on what transformer you use. You can even define your own one and "lift" would work as you write it. The only thing we know for sure is that whichever transformer you use, "lift" would have the type "m x -> t m x", where "t" is a transformer in question. So, it would be OK to apply it to, say, something of type "IO a", and you'd have something of type "t IO a" as a result.
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to