3 ms·
Imo, the advantage of "Haskell's approach" is that it's always obvious when you can and can't use imperative code, and the type system enforces it. I think this
by creata 5y ago
Imo, the advantage of "Haskell's approach" is that it's always obvious when you can and can't use imperative code, and the type system enforces it. I think this is important in many contexts, like STM[1] or Facebook's React[0]. But there are plenty of disadvantages:
* it's a bit more verbose.
* you can accidentally implement a weaker interface than the one you'd want, e.g. by only implementing Functor and not Traversable for your data structure.
* the flip side of the benefits is that adding I/O to a previously pure function changes its interface.
I don't know how it'd compare to OCaml's algebraic effects proposal, though.
[0]: https://reactjs.org/docs/hooks-effect.html https://reactjs.org/docs/hooks-effect.html
[1]: http://joeduffyblog.com/2010/01/03/a-brief-retrospective-on-transactional-memory/ http://joeduffyblog.com/2010/01/03/a-brief-retrospective-on-...