|
|
|
|
|
by mbrock
2390 days ago
|
|
Another way to say it: a monad is a generic type with the sufficient API to do binding sequences like x <- fetch "foo"
y <- frob x
return (x + y)
The meaning of binding/sequencing is decided by the particular monad instance. This is why it's a useful formalism to represent things like asynchronous I/O (you make the sequencing mean promise chaining), abortable computations (you make the sequencing cancel when it sees failure values), combinatorial/nondeterministic programming (you make it so one binding can happen several times).Monads are also closely related to continuation-passing style or delimited continuation capture, and those techniques can also be used to implement everything monads can. |
|