I remember the time before monads

Reference: I remember the time before monads

Paul Callaghan:

Callaghan's 1st Law: the need for mutable state in a language is inversely proportional to its flexibility in manipulating data

Put another way, mutable state is a lower-level idea and becomes less important when your language supports higher-level ways of working.


Experienced Haskell programmers know that the type system is a tool for getting work done, and a great language for playing with designs, and they exploit these aspects to help them get their work done.

The key word in the sentence above is "Experienced". It does take a long time to begin using the type system to your advantage.

It was however a time of exploration, when researchers explored various ideas to find a good way of both having our cake and eating it. Monads are one of the solutions they found, and essentially gave us a small but flexible API for working with "computations" (like IO operations or state modifications, or various combinations thereof) as opposed to simple data values, and did so elegantly within the standard langage (ie. no ad hoc extensions needed). It got even better when syntactic sugar was added.

Nice history lesson.

The piece ends with some good advice:

As a new explorer (very warm welcome, by the way!), when you look at Haskell material you may see some very unusual or scary-looking stuff. But do bear in mind that a lot of it is just playing around with abstractions on top of the core language, and probably does translate to something more intelligible. Try to work out what is being said about the data being manipulated, and then it might not look so bad.