3 ms·
The monad does enable imperative programming in Haskell, yes. But it is not needless complexity. It enables an imperative program to be assembled using a pure f
by willtim 8y ago
The monad does enable imperative programming in Haskell, yes. But it is not needless complexity. It enables an imperative program to be assembled using a pure functional program. Imperative statements become first class values, control flow constructs can be just user-defined functions, no macros needed.
Monads, of course, also allow us to change the meaning of a semi-colon. This can be used, for example, to implement lightweight fiber threads with custom schedulers, again all without macros.
It has been said that Haskell is the world's best imperative programming language: https://stackoverflow.com/questions/6622524/why-is-haskell-sometimes-referred-to-as-best-imperative-language https://stackoverflow.com/questions/6622524/why-is-haskell-s...