[Haskell-cafe] Mutable arrays

Bulat Ziganshin bulat.ziganshin at gmail.com
Thu Feb 7 05:29:48 EST 2008


Hello Jeff,

Thursday, February 7, 2008, 4:17:27 AM, you wrote:

> logical place for mutable arrays.  However, I don't understand the
> motivation for implementing it in IO.  Were mutable arrays added to
> IO because it would be difficult to write code that does both IO and manipulates arrays otherwise?

yes. you can't perform separate ST actions in IO monad, you may call
only entire computations with pure results - the same as you can do
from pure code

IO monad implements idea of sequencing actions and it is used ro
"import" any actions written in other languages (C/C++ in most cases).
ST monad is just the same internally but it was directive limited to
only two types of actions - with variables and mutable arrays. this,
together with some type tricks ensures that its results are
referentially-transparent and therefore may be called from pure code


-- 
Best regards,
 Bulat                            mailto:Bulat.Ziganshin at gmail.com



More information about the Haskell-Cafe mailing list