
On Tue, May 12, 2009 at 08:18:08AM -0700, Don Stewart wrote:
rjones:
I added some partial bindings for libguestfs[1] here:
http://git.et.redhat.com/?p=libguestfs.git;a=blob;f=haskell/Guestfs.hs;hb=HE...
Some very simple example programs which use these bindings:
http://git.et.redhat.com/?p=libguestfs.git;a=tree;f=haskell;hb=HEAD
Any comments welcome. My Haskell skills are pretty terrible, so I'm sure there are many ways these can be improved.
If someone wants to look at binding the rest of the API, then please send me some patches. (Note that the Guestfs.hs file is automatically generated).
Very cool. Are you likely to upload to hackage?
I think it should be a bit more complete before uploading it. It only covers about half the interface.
BTW, I found the documentation on writing FFIs very contradictory and incomplete. For example, I was completely defeated trying to find ways to do simple stuff like passing in integers or returning booleans. *Potentially* Haskell's FFI seems like it might be one of the best out of the languages I've used so far, but it needs way more documentation and examples.
Perhaps read the FFI chapter of RWH (online?)
What resources were you using to grok the FFI?
Well, Real World Haskell was one of the resources: http://book.realworldhaskell.org/read/interfacing-with-c-the-ffi.html (And it's fine, one of the better resources as an introduction. But not thorough enough to cover the booleans / returning complex structs problems I had). The others, as I remember it, were: http://www.haskell.org/haskellwiki/FFI_Introduction http://www.haskell.org/haskellwiki/FFICookBook (Made me think it was simple, but doesn't really cover much once I got down to the details) http://www.cse.unsw.edu.au/~chak/haskell/ffi/ & the documentation for 'Foreign' etc in the Haddock-generated library docs. Rich. -- Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://et.redhat.com/~rjones/virt-df/