FFI tutorial??

Manuel M. T. Chakravarty chak@cse.unsw.edu.au
Sun, 11 Mar 2001 14:53:07 +1100

Ronald Legere <rjljr2@yahoo.com> wrote,

> Does anyone know of a tutorial introduction to the
> FFI? How does one go about getting started with this
> thing? Any simple examples? 

Unfortunately, there is no tutorial style text about the FFI
yet - I agree that it is necessary to have one, but nobody
sat down and wrote one so far.

> I just want to be able
> to do simple things (mostly access a c library from
> haskell... ok maybe not trivial :) )  I would be
> happy if I could just call c programs with simple
> types and pointers (no way am I going to figure out 
> struct alignment! ). 

Have you had a look at the various tools that simplify
calling C code?  (The do stuff like figuring out struct
alignment automatically.)  There are four tools by now (in
order of increasing complexity and sophistication):

(1) hsc2hs: Comes with new versions of GHC.
(2) c2hs: http://www.cse.unsw.edu.au/~chak/haskell/c2hs/
(3) greencard: http://haskell.org/greencard/
(4) hdirect: http://haskell.org/hdirect/

You see - the Haskell developers believe in choice ;-)