Scalaz offers a nice abstraction over stateful computations: The ST monad.
The ST monad allows capturing a side-effecting computation in a functional form.
In Haskell, I suppose, using such a monad is the only way to implement some imperative algorithms efficiently.
But in Scala I can simply use mutable data-structures if necessary.
What I found out is, that using functional concepts from Scalaz comes with a computational overhead. See for example this question. Thus it does not seem reasonable to switch from a functional implementation to a functional implementation using the ST monad, if the desired goal is a gain in efficiency.
What I'm asking is thus:
- When is it reasonable to use the ST monad?
- In which situations did you use it and it appeared to be a good choice?