Array copy primops
Johan Tibell
johan.tibell at gmail.com
Tue Feb 1 16:40:43 CET 2011
On Tue, Feb 1, 2011 at 4:24 PM, Roman Leshchinskiy <rl at cse.unsw.edu.au> wrote:
> Johan Tibell wrote:
>>
>> Something struck me today. Look at the type signature for cloneArray#
>>
>>
>> cloneArray# :: Array# a -> Int# -> Int# -> State# s -> (# State# s,
>> Array# a #)
>>
>>
>> Does cloneArray# really have to take and return a `State# s`?
>
> Oops, no, it doesn't. This was purely a case of mindless copy-pasting.
Does this apply to any of the other primops? For your convenience,
here's the list:
copyArray# :: Array# a -> Int# -> MutableArray# s a ->
Int# -> Int# -> State# s -> State# s
copyMutableArray# :: MutableArray# a -> Int# -> MutableArray# s a ->
Int# -> Int# -> State# s -> State# s
cloneArray# :: Array# a -> Int# -> Int# -> State# s ->
(# State# s, Array# a #)
cloneMutableArray# :: MutableArray# s a -> Int# -> Int# -> State# s ->
(# State# s, MutableArray# s a #)
freezeArray# :: MutableArray# s a -> Int# -> Int# -> State# s -> (#
State# s, Array# a #)
thawArray# :: Array# a -> Int# -> Int# -> State# s -> (#
State# s, MutableArray# s a #)
It seems to me that maybe thawArray# doesn't need to take a state
token either as the input array can be copied at any point in time. Is
it even possible to return a MutableArray# without taking a state
token as an input parameter?
Johan
More information about the Cvs-ghc
mailing list