[Haskell-cafe] FPS lib

Donald Bruce Stewart dons at cse.unsw.edu.au
Tue Oct 18 07:24:42 EDT 2005

> On 18 October 2005 10:08, Krasimir Angelov wrote:
> > I am curious why FPS is implemented on top of ForeignPtr. ByteArray#
> > based implementation should be faster and more space efficient.
> Actually there's not much difference between ForeignPtr and ByteArray#,
> at least in GHC 6.5+ where we optimised the ForeignPtr implementation.  
> Furthermore ForeignPtr is much more useful, because you can create a
> ForeignPtr from a Ptr, and you can pass a ForeignPtr to C code portably
> (i.e. not using GHC extensions).  ForeignPtr is essential if you want to
> make packed strings from eg. mmap()'d memory.  

Right. And with a ForeignPtr, we can attach a finalizer, to e.g. unmap
mmapped regions.
> Also, a ForeignPtr allocated using mallocForeignPtr *is* a ByteArray#.

-- Don

More information about the Haskell-Cafe mailing list