
Hello List, Would someone kindly explain how the tell function interacts with the Writer Monad as show below: (Example taken from chapter 14 of LYAH http://learnyouahaskell.com/for-a-few-monads-more#reader ) multWithLog :: Writer [String] Int multWithLog = do a <- logNumber 3 b <- logNumber 5 tell ["Gonna multiply these two"] return (a*b) Result: ghci> runWriter multWithLog (15,["Got number: 3","Got number: 5","Gonna multiply these two"]) I know that tell function binds to an argument that is discarded but I don't know how its argument "Gonna multiply these two" is concatenated with the other the Writer created by logNumber 3 and logNumber 5. Also, I don't understand the paragraph following the example: "It's important that return (a*b) is the last line, because the result of the last line in a do expression is the result of the whole do expression. Had we put tell as the last line, () would have been the result of this do expression. We'd lose the result of the multiplication. However, the log would be the same." Regards, - Olumide