Hi all,<br><br>In order to improve my understanding of monad, I am trying to do some manual computation on "Reader Monad" but I got some problem.<br><br>The computation is like this:<br><br>--instance Monad (Reader e) where
<br>-- return a = Reader $ \e -> a <br>-- (Reader r) >>= f = Reader $ \e -> f (r e) e <br><br>runReader (do { b <- Reader $ show; return b } ) -- This is the initial expression, it should equals "show"
<br><br>runReader (Reader $ show >>= \b -> return b) -- remove do notion<br><br>runReader (Reader $ \e -> return( show e ) e) -- apply the definition of ">>="<br><br>runReader (Reader $ \e -> (Reader $ \e1 -> show(e)) e) -- apply the definition of "return"
<br><br>But the last expression is incorrect, and I don't know how to go on.<br><br>Could anyone explain this for me?<br><br>Thanks in advance!<br><br>Reference : <a href="http://www.haskell.org/all_about_monads/html/readermonad.html">
http://www.haskell.org/all_about_monads/html/readermonad.html</a><br>