From HaskellWiki
< HSFFIG(Redirected from HSFFIG Discussion)
Jump to navigation Jump to search

This page has been created to discuss any issues related to use of HSFFIG, yet another FFI binding modules generator for Haskell.

Would you mind explaining what HSFFIG is? Where is it? Can you provide some links or ideas?

Indeed, I just reserved this page with intention to write a little bit of the manual, and then the audience might have questions.

OK, let's start the discussion ;)

HSFFIG (Haskell FFI Generator) is a tool which given a .h include file (only C is supported) generates Haskell binding module(s) (if a module is small, it may remain as is, otherwise there is a splitter program which cuts a big module into small pieces). No wrappers, no interface files, just a header file. The output is a .hsc file (you will need a special hsc2hs template, template-hsffig.h included with hsffig)

Those who are already interested, may look here:


This is a message where I first announced it. It contains an URL, http://www.golubovsky.org/repos/hsffig/ where the darcs repo is visible through the web server. Look at the README file: it contains some introductory stuff. Go to the bdb directory: it contains an example of BerkeleyDB usage with Haskell (the binding module itself is not there, but there is a Makefile to create it - of course you need BerkeleyDB installed).

Finally, if interested, one may download one of the nightly DARCS snapshots here: http://www.golubovsky.org/software/hsffig/nightly/index.html or do
darcs get http://www.golubovsky.org/repos/hsffig (basically, same stuff).

Compile it, play with it, try it on various weird C include files. Let me know if there are some C constructs it breaks on. For instance, there is one:

typedef t a,b;

which is not that hard to fix, but I have seen it in only one header file so far.

I compiled it with GHC 6.2.2 (6.4 may complain on Data.FiniteMap), Alex 2.0, and Parsec included with GHC. Everything was done under Linux.

Hsffig stable version 1.0 has been released. The project is now hosted at Sourceforge:


Files in the locations mentioned above are still available, but the pre-release repo will no longer be updated.

A pre-release of Hsffig version 1.1 is available. See details here:


This pre-release includes a new addition: the FFI imports packaging utility (ffipkg).

Comments are welcome.