FFI Tutorial / Examples

Matthew Donadio m.p.donadio@ieee.org
Sun, 09 Mar 2003 22:13:35 -0500


Hi all,

I may be being a bit dense about this, but I am having some trouble
understanding how to use FFI, especially with respect to interfacing
Haskell lists/arrays to C arrays.

For example, say I have the C functions

void foo (double *input, double *output, int N);
double bar (double *input, int N);

and I want to create an FFI interface and have the resulting type
signatures be

> foo :: Array Int Double -> Array Int Double
> bar :: Array Int Double -> Double

where the bounds of the arrays are (0,N-1), and both foo and bar are
pure.  I read through the FFI docs, but I am still confused about how to
do this.  Can anyone point me to an FFI tutorial, or some examples? I
have a feeling that once I see some examples using lists and arrays that
things will fall into place.

Thanks.

-- 
Matthew Donadio (m.p.donadio@ieee.org)