Title: RE: Wanted: mmap or other fast IO

> Is there any interface to mmap(2) available? Something that
> behaves like
> an immutable array would be great.
>
> An mmap may have a signature like
>
> mmap :: Ix a, ?? b => Handle -> IO (Array a b)
>
> I've no idea what types should be allowed for b. It has to be
> some fixed
> size type, e.g. Int, but this would require the mmapped
> file's size to be
> a multiple of the size of Ints.

The easiest way is to declare mmap as a foreign function using foreign import, then build a little wrapper around it.  Unfortunately you won't be able to turn the resulting memory into an array (even a ByteArray), since these are assumed to live in GHC's heap, but you'll be able to return an Addr and use writeXXXOffAddr/readXXXOffAddr to access it(*).

Cheers,
        Simon

(*) the readXXXOffAddr functions are known to be broken at the moment (see recent discussion on ghc-bugs), we're currently working on fixing them.

Reply via email to