[Haskell] Haskell Xlib bindings

Sven Panne sven.panne at aedion.de
Mon Feb 12 14:07:19 EST 2007

On Monday 12 February 2007 18:34, Benjamin Franksen wrote:
> I agree that this would be nice. (Disclaimer: I haven't the slightest clue
> about XSLT and how it is used to generate code from XML protocol
> descriptions. However, I assume this won't be that much harder than to find
> some method to 'auto-ffi' the huge XCB_Protocol API into Haskell.)

The XSLT code to generate the C binding (c-client.xsl) is about 56kB. :-P 
Depending on the build system, personal preferences etc. it might make more 
sense to use Haskell code to transform the XML protocol description.

> Have you seen this:
> lists.freedesktop.org/archives/xcb/2006-January/001278.html ? The sources
> are here http://webcvs.freedesktop.org/xcb/xhsb/ It could be starting
> point, at least...

The code needs some tweaks to make it compile and work with my local XCB 
library. Anyway, this is only a tiny hand-written demo, not a starting point 
for a project.

> Yes, this is going to be the most difficult part. I have taken a look at
> another XCB paper, which is about the XCB_Connection layer and explains how
> the problem has been modeled using the Z specification language
> (freedesktop.org/software/xcb/usenix-zxcb.pdf). Very interesting, this. I
> wonder if one could derive a Haskell solution (more or less) directly from
> the Z spec. Or, maybe, even simplify the spec, leveraging Haskell's more
> high-level interface to multithreading (STM?).

Ignoring Z for the moment, I've started to hack the connection layer for XHB, 
which seems to be feasible. Two problems:

   * XCB depends on a handful XauFOO routines for authentication. It is not 
clear to me yet if we should do so in Haskell, too, or if we should 
re-implement that in Haskell, too. So for first tests no authentication will 
be offered. Welcome "xhost +"! ;-)

   * Haskell's standard networking libraries are really, really awful: No IPv6 
support, no getaddrinfo & friends, slightly obscure combination of features, 
one has to be careful about the byte order etc. etc.  This has been mentioned 
several times already, but I don't know if there is currently anybody working 
actively on this. :-(

Using formal methods somehow would be nice, but there are more fundamental 
things waiting to be solved, as it seems...

> Sources can be downloaded from the XCB site (a handful of tar.gz files).
> Build and install was rather uncomplicated here (debian/etch, amd64).
> Unfortunately, freedesktop.org seems to be down at the moment, so none of
> the above links will work until they are online again.

Using version control system no. x in my life (where x > 10 :-P * * *) to 
download the latest stuff, I've been able to build XCB locally. This is very 
straightforward after one has figured out the minimum amount of code to 


More information about the Libraries mailing list