3 ms·
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 b
by joelburget 16y ago
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.
- pjscott 16y agoReal 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-ffi.html 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.
- rwmj 16y agoI 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;hb=HEAD http://git.annexia.org/?p=libguestfs.git;a=tree;f=generator;...