Questions about the array APIs

Chris Kuklewicz haskell at
Wed Nov 15 12:46:47 EST 2006

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.

If you mean "can I treat the array as a large block of bytes as dump that to a
handle?" then you need Data.Array.IO.hPutArray and hGetArray.

Or possibly Data.Array.Storable with Foreign.Marshal.Array might help.

> 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.

More information about the Libraries mailing list