Monads are a useful tool in functional programming. Unfortunately, they're a pain in the ass to understand. I don't think they're actually that complicated, it's just that nobody seems to explain them well.
A monad is a collection which implements a flatMap
method. That's it.
flatMap
is a function made out of flatten
and map
: