[Haskell-cafe] State Variables

Bulat Ziganshin bulat.ziganshin at gmail.com
Tue May 30 02:53:57 EDT 2006

Hello Matthew,

Monday, May 29, 2006, 10:54:36 PM, you wrote:

> If possible I'd like to memory manage on the Haskell side.  All of the
> calls to BLAS and LAPACK that I'm aware of assume that
> all arrays are allocated outside of the C or Fortran that implement the
> matrix algorithms.  They never return buffers to
> newly allocated arrays. So what I'd like to do is something like 
> allocate an array in Haskell, freeze it and extract a  pointer,
> send it to the C code,  and then unfreeze it.  That way I benefit from
> Haskell's garbage collector.  Explicitly managing memory is a
> huge bug generator in C and C++.  In fact I'd say it's number one on the
> list.

> So can I modify Foreign Array to achieve this, or do I just end up with
> essentially a Storable Array?

you should use StorableArray. the speed drawbacks is larger overhead
for each access to array in Haskell code, including uses of
withStorableArray to call FFI operations. as far as most of your usage
of these arrays is to pass their addresses to FFI calls that process
many data (as opposite to FFI calls that process just several
elements), you will see no much penalty

> Maybe it would be just easier to use 6.5, though heaven knows what sorts
> of bugs may be lurking there.  I downloaded it already per your link.

you can try to compile with it just to compare speed. then you will
know how much you are lose

(sorry for my awkward english)

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

More information about the Haskell-Cafe mailing list