3 ms·
This is exactly where you might like to use the writer monad. Check out LYAH http://learnyouahaskell.com/for-a-few-monads-more http://learnyouahaskell.com/for-
by Tyr42 12y ago
This is exactly where you might like to use the writer monad. Check out LYAH http://learnyouahaskell.com/for-a-few-monads-more http://learnyouahaskell.com/for-a-few-monads-more
It's just a fancy name for composing functions of the form
`a -> (b, String)`, via
(>>=) :: (a, String) -> (a -> (b, String)) -> (b, String)
(a, log1) >>= f = let (b, log2) = f a in
(b, log1 ++ log2).