Array copy primops
Johan Tibell
johan.tibell at gmail.com
Tue Feb 1 18:34:02 CET 2011
On Tue, Feb 1, 2011 at 6:26 PM, Roman Leshchinskiy <rl at cse.unsw.edu.au> wrote:
> No, the operation is still impure. Suppose we had
>
> thawArray# :: Array# a -> Int# -> Int# -> MutableArray# s a
>
> Then, we write
>
> f xs = let ys = thawArray# xs 0 n#
> zs = thawArray# xs 0 n#
> in e
>
> Do ys and zs refer to the same MutableArray# in e?
>
>> Is it
>> even possible to return a MutableArray# without taking a state token as an
>> input parameter?
>
> No, for precisely this reason. In contrast to pure arrays, mutable arrays
> have an "identity", hence allocating them is impure.
Thanks for the clarification Roman. So the conclusion is that
cloneArray# loses its state token but everything else keeps it.
Johan
More information about the Cvs-ghc
mailing list