
On Fri, Mar 9, 2012 at 11:39 AM, Twan van Laarhoven
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.)
I believe you * don't have to use the return value from unsafeFreezeArray#, you can use the (now mutated) Array# initially passed to unsafeThawArray#, but * you must call unsafeFreezeArray# to make sure the header of the heap object is updated correctly. At least this is what I did in unordered-containers here: https://github.com/tibbe/unordered-containers/commit/428885cb1a62123921c22bc... Cheers, Johan