3 ms·
A monad is a "value" of a type X that depends on a type T: X[T]. It must have a "way" to take a function T -> X[T] and apply it to itself so as to get another X
by norswap 10y ago
A monad is a "value" of a type X that depends on a type T: X[T]. It must have a "way" to take a function T -> X[T] and apply it to itself so as to get another X[T].
Usually that "way" is a function called "bind" with signature:
(X[T], (T -> X[T]) -> X[T]
And that's really all there is to it.
Monads are fundamental only in the sense that there happens to be a lot of things for which these structures are useful (lists, optionals, effect wrappers, ...).