[Haskell-cafe] some newbie FFI questions

John Kozak jk at thameslighter.net
Thu Jul 1 13:58:29 EDT 2004

Alastair Reid writes:
 > [...]
 > Overall, I'd probably use an unboxed Haskell array.  This would let you get a 
 > memory layout (and memory consumption) close to the normal C layout.  I'd use 
 > access functions to hide the boxing/unboxing and I'd write some 
 > map/fold/scan-like functions to operate on the arrays.

Thanks (and thanks to the other respondents, too).  Using unboxed
arrays has got my load time down to 15s (from 45), which is OK.  

 > In some cases, I'd leave the object in the C world and access it using FFI 
 > functions and using various convolution operators written in C.  This works 
 > great if you already have a good image processing library, you're not 
 > interested in writing too many new image mangling functions of your own, and 
 > costs of copying the image from C to Haskell (and back again, no doubt), are 
 > excessive.  (I did this some years ago in a real time visual tracking system 
 > that had to deal with 640x512 images coming in at the rate of 30 frames per 
 > second.)

I found your FVision paper a couple of days ago - nice!


More information about the Haskell-Cafe mailing list