lambda fairy

Monads in 300 words

Many contemporary languages have one or more of these features:

In the 90s, programmers observed that all of these can be modeled by a single interface. They called the interface “monad” after a mathematical concept that looked similar. With this interface, they could define a single syntax and utility library that covers all three.

Cute!

Nano, a robot girl from the anime Nichijou, saying: “I think that’s moe\!”

Why don’t other languages have monads?

Good question.

Haskell, a pure functional language with fancy types and a heavy runtime system, is in a perfect position to support monads. But other languages have different goals in mind, and those goals might not align in the same way.

Should I care about monads?

If you are learning Haskell, or a similar statically-typed functional language, then understanding monads is a necessity. (If you’re not, then I recommend it. Functional programming is cool!)

But I don’t think reading tutorials is a good idea.1 “Monad” is but a small part of Haskell as a whole. Studying it in isolation, and expecting to understand anything, makes as much sense as learning Python through its descriptor system.

Instead, write code.

Play with async I/O.

Implement some type classes.

And at some point it’ll all make sense.

Hakase, a small girl from the anime Nichijou, in a cat costume.
  1. No, this article doesn’t count 🙂