[Haskell-cafe] State Variables

Bulat Ziganshin bulat.ziganshin at gmail.com
Mon May 29 14:16:39 EDT 2006

Hello Matthew,

Monday, May 29, 2006, 8:04:56 PM, you wrote:

> What is the difference between the ForeignArray defined in this source
> and the StorableArray?  The source code of both modules are very similar.

the devil in details :) - StorableArray in 6.4 is slow because it uses
ForeignPtr. there are two possible solutions - either speed up
ForeignPtr (done in 6.5) or use Ptr instead of ForeignPtr (used in my
module). of course in this case you lose all the benefits of
ForeignPtr's and in particular you will need to make explicit 'free'
if you create such array via 'newArray' or it's derivatives. if you
create such array via 'unsafePtrToForeignArray', then you don't need
to make any additional steps to free it's memory besides of that
required for StorableArray (i.e. in most cases it's the problem of FFI
library you are used)

simply speaking, if you don't create ForeignArray on the Haskell side,
it's as simple in use as StorableArray and as fast as IOUArray

Best regards,
 Bulat                            mailto:Bulat.Ziganshin at gmail.com

More information about the Haskell-Cafe mailing list