Skip to content

Comment on Monads for Normal Programmersparent

Comments

The distinction is not important in an eagerly evaluating language, which steps through its statements one by one and executes them as it finds them.

In a lazy, pure language it is of very great importance! With lazy evaluation you get no guarantees as to what order your expressions are evaluated in. Statements like "Blocks are evaluated in leftmost order" are just false in Haskell.

Monads give you the ability to sequence your I/O actions even though they are still lazily evaluated. This is why Haskell needs monads, and most other languages get by without them.

Another way to think of it is that monads are embedded into the operational semantics of eager languages, so you that the programmer doesn't need to be aware of them. After all, monads were initially used to formally describe the behaviour of ML, an eager language, before they were used in Haskell.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.