Re:Learn You a Haskell is now in print
by joelburget on Tuesday March 29, 2011 @02:57PM
(#2383894)
I've been writing some ffi myself code lately. The real world haskell chapter on ffi has been helpful. They use a bit of hsc2hs on top of plain ffi. I've also been using c2hs which does a lot of the work for you (a bit higher level) and have found Edward Z Yang's guide helpful for that.
[ Parent
| on HN ]
Real World Haskell is also online, by the way, so you can check out the chapter on FFI right here:
http://book.realworldhaskell.org/read/interfacing-with-c-the...
It walks you through making some basic PCRE bindings, which is a big enough example that they manage to touch on the important issues. It's a pretty good introduction, I would say, especially in the part that covers interfacing C strings with ByteStrings.
I read this when I was doing the original porting and TBH it's very lightweight.
Also (to reply to GP) c2hs is no use because we already have a very detailed and specific description of the interface, and a generator that does all the other bindings[1]. We want to know precisely how to translate our description into Haskell, we don't want to go through another layer.
[1] http://git.annexia.org/?p=libguestfs.git;a=tree;f=generator;...