Desugaring do-notation for Monads
As I'm learning Haskell I'm realizing that do notation is just syntatic sugar: a = do x <- [3..4] [1..2] return (x, 42) Translates into a = [3..4] >>= (\x -> [1..2] >>= (\_ -> return (x, 42))) I realize that I'll probably use do-notation but I'd like to understand whats going on in translation. So purely for pedagogical reasons, is there a way for ghc/ghci to give me the corresponding bind statements for a fairly complex monad written in do-notation? Edit. It turns out lambdabot on #haskell can do this: <Guest61347> @undo do x <- [3..4] ; [1..2] ; return (x, 42) <lambdabot> [3 .. 4] >>= \ x ->