
18 Mar
2012
18 Mar
'12
4:02 p.m.
On Sun, Mar 18, 2012 at 01:34:30PM -0400, Rohit Garg wrote:
Hi,
As I have been trying to learn the monads a bit more, I have come to realize that State monad doesn't actually represent state. It just provides a convenient glue for threading state. Is that correct?
Correct.
If so, then for performance using state monad is as good as not using it at all. Is there a way to have state with destructive update?
Yes, see the ST monad. http://hackage.haskell.org/packages/archive/base/latest/doc/html/Control-Mon... http://hackage.haskell.org/packages/archive/base/latest/doc/html/Data-STRef.... http://hackage.haskell.org/packages/archive/array/latest/doc/html/Data-Array... -Brent