[Haskell] Haskell Xlib bindings
benjamin.franksen at bessy.de
Mon Feb 12 12:34:39 EST 2007
Sven Panne wrote:
> Am Mittwoch, 7. Februar 2007 20:51 schrieb Benjamin Franksen:
>> XCB implements the full protocol (which already makes for a daunting
>> amount of data types and routines). On top of that it implements a very
>> lean connection management and request handling API that allows (this is
>> one of the highlights) single-threaded as well as multi-threaded access.
> Hmmm, the presentation in the paper is the other way round: The lower
> layer is the XCB_Connection layer, handling connections, requests and
> replies. On top of that, the XCB_Protocol layer implements, well, the
> protocol, including (un-)marshaling to/from C.
You're right, sorry for the confusion.
>> See the very readable paper
> After reading that paper and browsing around a bit, I think a slightly
> bolder approach might make sense for Haskell, in effect creating XHB ("X
> Protocol Haskell Binding"): I guess that the bulk of the code is in the
> XCB_Protocol layer, and that layer is already generated via an XML
> description for the C binding. If we can use the same technique to
> generate Haskell code, "only" a Haskell version of the connection layer
> would be needed to get a full XHB. This would have a few advantages:
> * There is no dependency on the XCB library, so XHB should work on
> platform, including e.g. MinGW without any X11 libs. An X11 server is of
> course still needed... :-)
> * Data is only (un-)marshaled once. Using XCB, there would be 2 steps:
> Haskell <=> C <=> X protocol
> * The availability of protocol extensions is determined by XHB alone,
> by any underlying XCB implementation.
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.)
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...
> I am not sure if this is a realistic way to go, especially I am unsure
> about the amount of work needed to implement the functionality of the
> XCB_Connection layer directly in Haskell.
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?).
> Let's see if I can find a more
> or less stand-alone version of XCB (with no need to build all of X.Org)
> and understand how it is actually implemented.
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.
More information about the Libraries