Monads are about sequencing. They are an interface to force applying functions in a particular order. This is why Haskell needs them -- in a language with only pure functions, there's no way to encode (for example) the order of 'print' statements directly, it has to be expressed in terms of combining functions.
Consider the interface, expressed in a C-like syntax:
interface Monad {
template<A>
from(value: A) => Self<A>;
template<A, B>
sequence(self: Self<A>, f: fn(A) => Self<B>) => Self<B>;
}
You can see that it forms a sort of one-way valve for functions from one value to another.Types you could implement that interface for:
* Lists: `from` wraps the value in a size=1 list, and `sequence` becomes "apply the function to each value then concatenate the results".
* Optional: `from` is the case of a value existing, and `sequence` is "if value exists then apply the function, else return None".
* Sets: same as lists.
But it's hard to write a blog post about an interface with only two functions, especially if you've already committed a thousand words to making it seem complicated.