Mutable arrays

Koen Claessen
Thu, 8 May 2003 14:34:14 +0200 (MET DST)

Dear all,

I wonder if anyone knows a good way of giving an unboxed
mutable array (e.g. IOUArray) to the C world using the FFI
in constant time? (I.e. a conversion to a Ptr.)

I presume that an IOUArray is implemented as nothing but a
Haskell object that has some information plus a pointer to a
"normal" C array. I would like to get to that pointer!

I could of course implement my own verion of IOUArray which
uses a Ptr inside, but it seems silly to redo all the work
that has gone into IOUArray.

I have also a feature request for mutable arrays: Is it
possible to prove a function like "realloc" which extends
the array to a larger size, copying all existing
information? Right now, I have to do this myself; I am using
a type 'IORef (UArray ..)' which seems kind of silly and
unnecessarily inefficient.