Goto in Haskell: Can anyone explain this seemingly insane effect of continuation monad usage?

Here’s a somewhat informal answer, but hopefully useful. getCC’ returns a continuation to the current point of execution; you can think of it as saving a stack frame. The continuation returned by getCC’ has not only ContT‘s state at the point of the call, but also the state of any monad above ContT on the … Read more

Has anyone ever encountered a Monad Transformer in the wild?

The Haskell community is split on this issue. John Hughes reports that he finds it easier to teach monad transformers than to teach monads, and that his students do better with a “transformers first” approach. The GHC developers generally avoid monad transformers, preferring to roll up their own monads which integrate all the features they … Read more

Simplest non-trivial monad transformer example for “dummies”, IO+Maybe

This is available here as a .lhs file. The MaybeT transformer will allow us to break out of a monad computation much like throwing an exception. I’ll first quickly go over some preliminaries. Skip down to Adding Maybe powers to IO for a worked example. First some imports: import Control.Monad import Control.Monad.Trans import Control.Monad.Trans.Maybe Rules … Read more

Is there a monad that doesn’t have a corresponding monad transformer (except IO)?

I’m with @Rhymoid on this one, I believe all Monads have two (!!) transformers. My construction is a bit different, and far less complete. I’d like to be able to take this sketch into a proof, but I think I’m either missing the skills/intuition and/or it may be quite involved. Due to Kleisli, every monad … Read more

tech