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

mtl, transformers, monads-fd, monadLib, and the paradox of choice

A bunch of them are almost completely equivalent: mtl uses GHC extensions, but transformers is Haskell 98. monads-fd and monads-tf are add-ons to transformers, using functional dependencies and type families respectively, both providing the functionality in mtl that’s missing from transformers. mtl-tf is mtl reimplemented using type families. So essentially, mtl == transformers ++ monads-fd, …

Read more