[Xmonad] xmonad is a zipper
Donald Bruce Stewart
dons at cse.unsw.edu.au
Thu May 17 00:19:03 EDT 2007
ndmitchell:
> Hi
>
> And once again, firing Catch (google:catch haskell) off on this code:
>
> * new calls error, not a big surprise that this makes it incomplete
>
> * view also calls error
>
> * swap calls tail, which isn't safe unless you know some seriously
> deep stuff about index, and keep a detailed mapping between elements.
> The basic problem is that Catch can't know that successive calls to
> Map.lookup with the same key give the same results. You can probably
> eliminate this by only performing one lookup, which is also faster.
Good suggestion.
>
> * delete and focusWindow both call focus, which is incomplete. Both
> feature very similar code, and could do with abstracting out. The
> basic pattern is:
>
> focus (stack (current s))
>
> which is unsafe - since stack may return Empty, for which focus is
> incomplete.
A bug! Well spotted.
>
> * new relies on the Integral type having sensible semantics, if you
> pass Int or Integer its fine (machine checked), but if you create a
> crazy type, make it an instance of Integral then [0..n-1] may generate
> no elements, and your (h:t) match will fail.
Tricky.
>
> All the rest of the program is safe, including the partial 'with'
> function, as specifically annotated by dons to check.
Very good Neil, thanks!
I've written up the idea behind implementing xmonad as a zipper-based
data structure which tracks focus for us here,
http://cgi.cse.unsw.edu.au/~dons/blog/2007/05/17#xmonad_part1b_zipper
For those wondering how the new StackSet data type will work. The plan
is to merge in my zipper branch in the next few days.
-- Don
More information about the Xmonad
mailing list