[Haskell] Re: ST/STRef vs. IO/IORef

Sebastian Sylvan sebastian.sylvan at gmail.com
Thu Aug 4 18:05:29 EDT 2005

On 8/4/05, Till Mossakowski <till at informatik.uni-bremen.de> wrote:
> Remi Turk wrote:
> > MonadState needs multi-parameter type classes, State and StateT
> > don't. And ST needs rank-2 types (or at least one rank-2
> > constant) and, to be implemented _efficiently_, also needs
> > something like unsafePerformIO (or even lower-level unsafe
> > mutable state primitives).
> > I think one could call the ST monad a safe yet still efficient
> > variant of unsafePerformIO + IORef's + IOArray's.
> No, the point of ST is that it is safe (as opposed to unsafePerformIO),
> but still has the advantages of being both efficient and allowing
> purely functional encapsulation via runST (as oppesed to IORefs
> and IOArrays). The only price is that you need rank-2 polymorphism
> and new language primitives for creating, reading and writing
> references. But using these primitives is much better than using
> unsafePerformIO - the latter entails a lot of harmful things.

Hmmm... Wasn't that what he said?


Sebastian Sylvan
UIN: 44640862

More information about the Haskell mailing list