3 ms·
Slightly OT: Can someone point to a good, comprehensive tutorial on how to call C code from Haskell? Background: libguestfs Haskell bindings need a lot of love
by rwmj 16y ago
Slightly OT: Can someone point to a good, comprehensive tutorial on how to call C code from Haskell?
Background: libguestfs Haskell bindings need a lot of love, and the FFI deeply confuses me.
- joelburget 16y agoI'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;...
- ionfish 16y agoAside from the reading material others have suggested, I strongly recommend the #haskell channel on Freenode. The people there are extremely helpful and friendly.
- neutronicus 16y agoSeconded. #haskell and #lisp on freenode are both great.
- rtaycher 16y agoI found #squeak and #csharp quite good