How unsafe are unsafeThawArray# and unsafeFreezeArray#

Twan van Laarhoven twanvl at gmail.com
Fri Mar 9 20:39:18 CET 2012


On 2012-03-09 02:13, Johan Tibell wrote:
> Hi,
>
> I just ran across some code that calls unsafeThawArray#, writeArray#,
> and unsafeFreezeArray#, in that order. How unsafe is that?

Quick follow up question:

Are unsafeThawArray# and unsafeFreezeArray# guaranteed to not make a copy? I.e. 
are these two pieces of code equivalent with respect to further usage of the 
return value:

     do mary <- unsafeThawArray# ary
        writeArray# mary 123# newValue
        unsafeFreezeArray# mary

and

     do mary <- unsafeThawArray# ary
        writeArray# mary 123# newValue
        return ary

(where do notation is actually done manually.)


Twan



More information about the Glasgow-haskell-users mailing list