The Best Explanation of Monads I've Seen

Posted on July 30, 2009

I will freely admit that there is a strong part of me that likes Haskell. I think it’s the part of me that has a little mathematician envy. I have a small collection of books on prime numbers, the evolution of maths, and even a few practical ones on geometry and number theory. This part of me reasons that processes can be expressed mathematically and deterministically and that view fits rather well into how Haskell tries to see the world.

Generally I’ve been more of a pragmatist. As a programmer I’ve largely held the belief that one cannot be purely functional in a non-deterministic world. I think I’ve developed this notion over the years as I evolved my programming career from assembler, to C, to Perl, Python, and so forth. In these languages I was taught that functions just return values (the mathematician sighs). Working with these languages to wrestle every day problems like parsing mangled data and coercing them into readable formats reinforced the idea that such a task would be practically impossible to describe without the flexibility to be imperative and abuse side-effects. My proof that non-determinism was inescapable? A solid lack of understanding as to how Haskell’s monads work. “Look!” the pragmatist would ignorantly decry, “even Haskell can’t escape it!”

Little did I know what Haskell’s monads really do! This video sums it up rather well: