4 ms·
Yes, 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 effe
by panic 11y ago
Yes, 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.