[Haskell] Haskell Xlib bindings

Benjamin Franksen benjamin.franksen at bessy.de
Mon Feb 12 16:49:37 EST 2007


Sven Panne wrote:
> 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.

Yup. I didn't look at teh XSLT code before, but I have now: it looks
awefully baroque. The /must/ be a simpler way, or at least a less verbose
one.

>> 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.

Ok; I haven't looked at it very closely.

>> 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 +"! ;-)

I agree that this can be postponed.

>    * 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...

>From what I read in the ZXCB paper, the specification of the connection
layer is somewhat tricky to implement correctly, at least when based on the
semantics of Posix threads (and with the stated requirement for an API that
can be used equally well for single and multi threaded clients). It could
well be that an implementation in Haskell would have less problems with
this aspect, and more with insufficient library support. Disclaimer: I
haven't done any serious network programming in Haskell yet, so I'll have
to take your word on this. And before I forget it, another one: I find this
(potential) project very fascinating, but I doubt my Haskell programming
abilities are good enough to contribute significant amounts of code to it.

Cheers
Ben



More information about the Libraries mailing list