[xmonad] Re: Compile-time verification of keymaps

Adam Vogt vogt.adam at gmail.com
Wed Mar 24 02:36:32 EDT 2010

* On Wednesday, March 24 2010, Ivan Miljenovic wrote:

>On 24 March 2010 10:25,  <wagnerdm at seas.upenn.edu> wrote:
>> Surely this solution is too complicated, given that
>> "-fwarn-overlapping-patterns" works perfectly well and is built into GHC.
>Does that work if addKeysP is used?  (Does gwern's patch work in that case?)

The quasiquoter does work for either style of keybinding, though for
that purpose the implicit Map.fromList shouldn't be included in the QQ.

I don't quite understand how -fwarn-overlapping-patterns can be used to
avoid overlapping keybinds: you suggest replacing the (Map Key (X ()))
with a function   (Key -> Maybe (X ())) (with the maybe possibly added
by catching pattern match failures)?  Performance probably doesn't
matter here, but I believe pattern matches are tried one after the
other, as compared to Data.Map which is a bit smarter than that.

More importantly, xmonad needs to be able to tell the xserver which keys
it will be listening to, which may be a bit awkward with the function

But neither the function or the QQ approaches seem to be terribly
composable (in that they miss overlapped bindings if you try to combine
bindings defined in separate places). The use of HList instead looks
like it could avoid that and still enforce no-duplicates no matter where
the keybindings come from, though there would be a bit of effort
involved to generate the record keys.


More information about the xmonad mailing list