Most generated functions in xhb have types similar to those below:
createWindow :: Connection -> CreateWindow -> IO () grabKeyboard :: Connection -> GrabKeyboard -> IO (Receipt GrabStatus)
Those requests which expect responses can wait for them as follows:
getReply :: Receipt a -> IO (Either SomeError a)
Some functions are a bit different (request parameters don’t live inside a dedicated type, but are passed directly to the function):
configureWindow :: Connection -> WINDOW -> ValueParam Word16 -> IO () queryTextExtents :: Connection -> FONTABLE -> [CHAR2B] -> IO (Receipt QueryTextExtentsReply)
Nevertheless, thanks to disciplined code generation, xhb has a clean and uniform code base. The xhb-requests package wraps all of these generated request functions in two classes:
class Request a where requestIO :: a -> Connection -> IO () class RequestWithReply a b | a -> b, b -> a where requestWithReplyIO :: a -> Connection -> IO (IO (Either SomeError b))
The instances of this class are generated from the xhb source which is itself generated from XML protocol documents. This may sound ugly, but it worked quite well.
This package is the foundation for xhb-monad and friends.
This article describes this set of packages in detail.
Haddock can be found here.
Nix is used to build this package.
./build-utilscontains the program that generates
Graphics.XHB.Requests.Internal.Instances.*from the xhb source.
- The nix expression in
./xhb-requests-src.nixshows how it is used.
- That expression describes a derivation containing the entire source of the package
./xhb-requests.nixdescribes the package itself.
./mklinks creates symlinks in
. to the generated source in
/nix/store to allow you to develop normally (e.g. with