Re: [Haskell-cafe] Mutable but boxed arrays?

2007-09-06 Thread Ketil Malde
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, on the other hand, have always wondered why the strict arrays are
called unboxed, rather than, well, strict?  Strictness seems to be
their observable property, while unboxing is just an (admittedly
important) implementation optimization.  I imagine that it'd be at least
as easy to implement the strictness as the unboxedness for non-GHC
compilers, and thus increase compatibility.

-k


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Mutable but boxed arrays?

2007-09-06 Thread Henning Thielemann


On Wed, 5 Sep 2007, Jonathan Cast wrote:


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


I was imprecise here. With 'access' I meant an access to the array outside 
of the ST monad, that is on the result of runSTArray.



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.


I'll see, if I understand it.

  do writeArray arr 0 2
 x - readArray arr 0
 writeArray arr 0 (x+x)

If 'arr' is an STArray, the 'arr' will contain the unevaluated expression 
2+2 as zeroth element and with type STUArray it will contain the 
evaluated 4 ?

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Mutable but boxed arrays?

2007-09-06 Thread Isaac Dupree

Ketil Malde wrote:

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, on the other hand, have always wondered why the strict arrays are
called unboxed, rather than, well, strict?  Strictness seems to be
their observable property, while unboxing is just an (admittedly
important) implementation optimization.


Unboxing is, unfortunately, observable: it is not so easy to make a 
strict array of SomeArbitraryAlgebraicDataType, because it's not in 
class Storable.


Isaac
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re[2]: [Haskell-cafe] Mutable but boxed arrays?

2007-09-06 Thread Bulat Ziganshin
Hello Isaac,

Thursday, September 6, 2007, 9:41:34 PM, you wrote:
 Unboxing is, unfortunately, observable: it is not so easy to make a
 strict array of SomeArbitraryAlgebraicDataType, because it's not in 
 class Storable.

parallel arrays in GHC is just about it


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe