Questions about the array APIs

Iavor Diatchki iavor.diatchki at gmail.com
Thu Nov 16 13:04:08 EST 2006


Hello,

On 11/15/06, Chris Kuklewicz <haskell at list.mightyreason.com> wrote:
> Iavor Diatchki wrote:
> > Hello,
> > I have two questions about the array APIs in the libraries:
>
> > 1. Is there a way to write an immutable array to a handle without
> > using any unsafe methods?
>
> In what format?  There is no canonical form for an IArray except for Show/Read.
I should have been more clear.  I was thinking of an array of bytes,
and I was wondering if there is a function like 'hPutArray' from
Data.IO.Array that works on immutable arrays (e.g, ordinary Haskell
arrays, or unboxed immutable arrays of bytes).  Using 'hPutArray' is
not good in this case because to turn an immutable array into a
muttable one we have to copy it.

> > 2. Why does the function 'getBounds' (of the 'MArray' class) return
> > its result in a monad?
>
> It is so that mutable arrays which dynamically change their bounds can be supported.
There do not appear to be methods in the MArray class that allow
arrays to change their bounds...

-Iavor


More information about the Libraries mailing list