3 ms·
Monads are generally useful beyond IO, and pure programming style is available (and recommended) in almost every language. From the article you linked: "Altho
by gohrt 11y ago
Monads are generally useful beyond IO, and pure programming style is available (and recommended) in almost every language.
From the article you linked:
"Although Wadler’s development of Moggi’s ideas was not directed towards the question of input/output, he and others at Glasgow soon realised that monads provided an ideal framework for I/O."
- panic 11y agoYes, definitely. To be clear, I'm a fan (and long-time user) of monads in Haskell, and I think they're a great solution to the problem of embedding impure effects in a pure language. I just don't understand why you'd use them in a language where you can just write the impure effects in a direct style, especially when there's no 'do' notation equivalent.
- Retra 11y agoYou don't usually need them to do IO and state, but they're useful for things like optional and error values. Otherwise, it is mostly pedagogical. Besides, writing things that exist in other languages is useful when you're writing other languages. If you were using C to write a new language with closures (for instance,) you're going to have to implement closures in C. That's a useful exercise, even if nobody is going to use such an inevitably clunky construct in C directly.
- tel 11y agoYou use them precisely when you need a computational/imperative context which differs from the natural ambient one of your language. E.g., Promises in Javascript.