
26 Jan
2017
26 Jan
'17
10:41 a.m.
Hello List, Chapter 14 of LYH ( http://learnyouahaskell.com/for-a-few-monads-more#reader ) has the following bit of code: import Control.Monad.Writer logNumber :: Int -> Writer [String] Int logNumber x = Writer (x, ["Got number: " ++ show x]) multWithLog :: Writer [String] Int multWithLog = do a <- logNumber 3 b <- logNumber 5 return (a*b) I have a fair grasp of what's going bu the last line return(a*b) eludes me. Specifically its the a*b part that baffles me. I think 3 is bound to 'a' and 5 to 'b', then return(a*b) would put the value 15 in a context ... So what becomes of the string parts of the Writer monads created by logNumber 3 and logNumber 5 respectively. Regards, - Olumide