[Haskell-cafe] Monads because of I/O?
Olaf Klinke
olf at aatal-apotheke.de
Sun Jul 15 20:06:08 UTC 2018
Paul,
monads were not invented because I/O could not be presented in another way
in Haskell. Monads are way older than Haskell. It is a concept of category
theory which was developed in the 1950s. Actually some concepts of algebra
that are even older turn out to be monads. Take Galois theory for
example. Once you know the pattern, you find a monad under every stone you
turn around. It's one of the luckiest things that people like Moggi and
Wadler realized that monads can be applied to structure programs. And
don't blame them that monads are not composable - it is simply a
mathematical fact. Some monads do compose with any other monad, and those
are the monad transformers.
If you like Prolog's relational programming model so much, then you should
play with those programs that have "no business value". Because Haskell's
type inference algorithm, together with multi-parameter type classes and
maybe type level natural numbers together give rise to Prolog-like
capabilities. All the work is done by the compiler this way.
What you say about FSM is certainly true to some extent - they are well
understood, can be generated automatically, and there is decent theory to
reason about them. That is why this model is used in safety-sensitive
environments such as aviation. I once applied for a position in
verification in the automotive industry, and the interview partner told me
that they struggle mightily with the vast state spaces of the FSMs they
are checking.
All this speaks in favour of Haskell. The semantics is simple and
beautiful, because it is a single-paradigm language. And because of that,
clever people can leverage theorem provers to mathematically prove
correctness of Haskell code. I don't know of many languages where that is
possible. (But then, I'm not an expert on verification.)
Olaf
More information about the Haskell-Cafe
mailing list