[Haskell-cafe] FFI basics

Bulat Ziganshin bulat.ziganshin at gmail.com
Tue Feb 27 03:30:40 EST 2007

Hello Evan,

Tuesday, February 27, 2007, 12:02:57 AM, you wrote:

> Unfortunately, ghc doesn't seem relink the target if cfile.o changed,
> so as a hack I put 'rm target' before the ghc line to make it link
> every time.

it's a bug. i don't know whether it's already fixed, try it with the
latest 6.6 snapshot

> #2 is structs.  What's a good way to marshal structs?

this depends on your actual task. in particular, you can write
instances of Storable for your structures:

instance (Storable a, Storable b) => Storable (a,b) where
  sizeOf (x,y) = sizeOf x + sizeOf y

hsc2hs translator allows you to use offsets in C structures, see
Best regards,
 Bulat                            mailto:Bulat.Ziganshin at gmail.com

More information about the Haskell-Cafe mailing list