Jabberwocky

snicker-snack!

Monads: Best Sources

| Comments

I wrote a blog post about Monads about a year ago. Now, after about 1 year into full-time Haskell, my perspective has changed somewhat. With monads you keep all functions in your program pure, by passing in the world (or a relevant subsection thereof) and outputting the calculated value including world modified by side effect (or relevant subsection thereof).

I’ll humbly take a step back and point to the best sources to learn about Monads (and monad transformers):

  • Trivial Monads: starting with the simplest monad, with bonus exercises. This blog, A Neighbourhood of Infinity, is a good one to bookmark if you’re into Haskell.
  • Monad transformers, step by step – longer (16 pages), but full of goodness, at least in my opinion. Slow construction and enhancement of an interpreter of a very simple programming language.

Last one is an illustration of a general factoid concerning Haskell: sometimes the best source is the originating academic paper. The docs often explicitely refer to the paper, probably figuring that this is the most complete and correct explanation. After being put off initially, I’ve come to see that there are good sides to this approach – getting into the habit of reading a paper once in a while is probably good for the brain (and I’m definitely not the first to come up with that idea, see the Papers we love meetups). The negative side to this is that most of us don’t have unlimited time to pore over densely written papers.

The monads transformers paper was written using Literate Haskell, which I’m starting to be a big fan of. In a literate Haskell program, the code is secondary to the explanation. It may not be useful for every utility function file, but it makes for great documentation, and can be converted to PDF via TeX.

Comments