how implement a UArray with a ForeignPtr?

Ross Paterson
Sat, 19 Jul 2003 13:40:30 +0100

On Sat, Jul 19, 2003 at 08:17:10AM -0400, David Roundy wrote:
> Hello.  I was wondering if there might be any relatively simple way to
> implement a type equivalent to UArray, but with the memory stored in a
> ForeignPtr? It seems like this would be a commonly useful situation, where
> you have a C function that returns a pointer to an array of data, and it
> would be nice to be able to access that data without making a copy of it.

StorableArray does this for mutable arrays, and this is the way the CVS
version of Hugs implements UArray (cf hugs98/libraries/Hugs/ByteArray.hs).