The following commentator writes:

Monads are a unification of a bunch of computer stuff, including sequencing, IO, non-determinism, state, concurrency and exceptions. When I say "unification", I mean it in the sense that Newton's theory of gravity unified the motion of the planets with a falling apple (previously they were considered separate phenomena), or how Maxwell's equations unified electricity and magnetism. Once you grok monads you realise that all those different things I listed are just special cases of one overarching theory.

My question is: Are monads a unification of a number of computer science concepts?


1 Answer 1


It depends on your interpretation, I guess.

Is an Iterator interface a unification of arrays, lists, sets, strings, and input streams?

Because that is essentially what a monad is: an interface. It is just at a higher level of abstraction than the typical interfaces programmers are used to.

Monads are an abstraction that essentially represents "computation plus some structure". And it turns out that, indeed, many concepts in computer science can be molded into the form of a monad. The IO monad represents side-effecting computations, the State monad represents computations with mutable state, the STM monad represents concurrent computations with transactional state, the Error monad represents computations that could fail, the Maybe monad represents computations that may or may not return a useful result, the Continuation monad represents control flow, the List monad represents … and so on and so forth.

For example, in .NET, monads are used to abstract over database queries, collections operations, reactive programming, and many more. And of course in Haskell, you can't really write a useful program without at least the IO monad.

What this means is that monads allow you to interact with non-determinism, concurrency, side-effects, errors, etc. through the same interface. Which of course also means that you can write libraries, helpers, programs, and abstractions that only depend on the monad interface and thus automatically work with all of those.

Whether or not you consider that "unification" is probably more a matter of opinion. Like I said: if you say that monads unify all these things, then you also need to say that iterators unify arrays, lists, etc.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.