[Haskell-cafe] Get out structured data from a C/C++ library inHaskell

Nicola Gigante nicola.gigante at gmail.com
Fri Aug 8 17:51:16 UTC 2014


Il giorno 08/ago/2014, alle ore 17:29, Donn Cave <donn at avvanta.com> ha scritto:

>> How can I do that? In general, I've only seen example of how to exchange
>> primitive types with C functions through the FFI, but not for example
>> structures or pointers to structures.
> 
> Foreign.Storable is the key to packing and unpacking a struct.  The
> hsc2hs utility adds some support for struct member names, which will
> make your code more convenient and robust.  You will also find "peek"
> and "poke" functions in Foreign.Storable, for pointer access.

Thanks! 

Is this the approach used by the llvm-general library?
Moreover, I see that peek and poke return IO a, so I 
can't pretend that the interface that I'm wrapping is pure,
can I?

Nicola



More information about the Haskell-Cafe mailing list