[Haskell-cafe] Mutable but boxed arrays?
jcast at ou.edu
Wed Sep 5 12:15:18 EDT 2007
On Wed, 2007-09-05 at 20:37 +0200, Henning Thielemann wrote:
> Can someone explain me, why there are arrays with mutable but boxed
> elements? I thought that boxing is only needed for lazy evaluation.
> However if I access an element of an array that is the result of a
> sequence of in-place updates, all updates must be executed in order to get
> the final value. That is, the first access to an element of such an array
> evaluates all elements of the array
No. A mutable array is mutable only in a monad (IO or ST), and updates
happen within that monad. But they don't evaluate the values in the
array at all, either the old value or the new one. They just move
pointers to expressions in the heap around.
More information about the Haskell-Cafe