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!
立刻下载 MSN 保护盾,保障Messenger 安全稳定! 现在就下载!