3 ms·
This is just not true, you throw out some of the most useful monads :) Also ST and State have no side effects. The only monad in Haskell that has side effects
by nightski 5y ago
This is just not true, you throw out some of the most useful monads :)
Also ST and State have no side effects. The only monad in Haskell that has side effects is IO (unless you were to sneak in an unsafePerformIO but that is an entirely different discussion). So they aren't there to work around the limitations of purity, because they are pure.
- sltkr 5y ago> This is just not true, you throw out some of the most useful monads :) Namely? > Also ST and State have no side effects. I didn't say they do. I said they are useful only because Haskell doesn't allow side-effects. In ML or Lisp you'd just update a local variable instead.
- nightski 5y agoLists, Option, Either, Reader, Logging (non-effectful), STM etc... There is even a probability monad that I have found quite useful. ST & State are far more useful than updating a local variable. If you are going to choose the simplest use case for them ever and then say that is the only thing they can do it is not a productive discussion. The state monad is a lot like a context object that allows state to flow through function composition (for functions that have no knowledge of such state). For example you could compose a bunch of functions and have the results of each function call stored without changing any of the functions to know about the operation. It's a method of abstraction and encapsulation. It's not just monads that are useful either, it is the full hierarchy of Monoids, functors, applicatives, monads, etc...