What is a Monad?

January 14, 2016

A discussion was going around in a facebook group on how can we define monad? Many people commented there, but I wasn’t satisfied with any of the answers (including mine), until Edward Kmett came up with this explanation:

A monad is anything satisfying the two operations and three laws.

When you restrict yourself to talking about the category of Haskell data types:

This happens to include things that look like context-sensitivity, but that analogy sorts of breaks down when you talk about things like fixed-length vector data types.

They happens to include things that look like containers, but that analogy breaks down when you consider things like state or IO.

It happens to include how we handle IO and State, but those things don’t feel like the rest.

Each of those 3 perspectives that people offer up is sort of the viewpoint of one of the 3 blind men groping the elephant, so I tend to limit my ‘what a monad is’ understanding to the operations and laws.

https://en.wikipedia.org/wiki/Blind_men_and_an_elephant

When you take a larger perspective than just the category of Haskell data types the idea of a monad is quite fundamental and all sorts of things turn out to be monads, so it is well worth studying what things can comply with the laws. The rabbit hole runs deep.

The above description is so perfect! Years ago, when I was learning Monad, I was looking for such an interpretation.