realloc for I/MArrays

Hal Daume III hdaume@ISI.EDU
Fri, 19 Apr 2002 11:15:44 -0700 (PDT)

Any chance IArrays (or MArrays) will some day support something like:

resize :: (Ix ix, IArray a e) =>
          a ix e -> (ix,ix) -> a ix e

that is faster than allocating a new array and then copying
value-by-value?  perhaps make the result a Maybe (a ix e) in the same way
that realloc can return null if it can't get you more memory at the end 

or even just a simple memcpy like function so you could allocate a new
array with the same index and element type and then copy directly from one
to the other, like:

arrcopy :: (Ix ix, IArray a e) =>
           (ix -> ix) -> a ix e -> a ix e -> a ix e

which can possibly fail if the indices for the destination don't line up
with the source properly?

i don't know enough about how UArrays are implemented in ghc to know if
this is even reasonable, but if it's possible, can we expect to see
something like this?  :)

 - Hal

Hal Daume III

 "Computer science is no more about computers    |
  than astronomy is about telescopes." -Dijkstra |