
24 Dec
2012
24 Dec
'12
6:47 a.m.
Hello. Could you explain this example(0)? Could you show its step by step execution? gcd' :: Int -> Int -> Writer (DiffList String) Int gcd' a b | b == 0 = do tell (toDiffList ["Finished with " ++ show a]) return a | otherwise = do result <- gcd' b (a `mod` b) tell (toDiffList [show a ++ " mod " ++ show b ++ " = " ++ show (a `mod` b)]) return result Why does the above append the log to the beginning of the list? What value will result have in the following? result <- gcd' 2 (3 `mod` 2) (0) http://learnyouahaskell.com/for-a-few-monads-more#writer