[xmonad] darcs patch: The start of a LayoutCombinator class with a CombinedL...

Andrea Rossato mailing_list at istitutocolli.org
Tue Jan 29 12:44:03 EST 2008


this is a step forward in the direction of the type classes cleanup
I've been proposing recently.

The basic idea is to completely hide the Layout implementation to
LayoutModifiers and LayoutCombinators. This way we can extend the
LayoutClass without messing up the whole repository.

This should also let us remove a lot of duplicate code and let the
developers not to rewrite always the same stuff with high probability
of bugs.

This way we could also reject any code that has a (wrs,ml) <- doLayout
in a LayoutClass instance...;)

While there seems to be not much use for such a class (well,
PerWorksapce, ToggleLayouts, MultiToggle, LayoutCombinators, the
layout selector, and so on...;), while implementing it I had the
feeling it could be quite a powerful tool. Imagine to run 2 layouts
and then combine their results with pure code with "combineResult"...
I don't know, but that could be fun.

Still I have some troubles in implementing the handleMessage methond
for CombinedLayout - and in deciding the type of comboHandleMessage.
If we switch layout, the first one should receive an Hide. Should I
take care of that in the class? In the instance?

David, any idea?

That following would be the implementation of a simple Toggle layout
combinator. It works (sendMessage Toogle will make it switch), but I
still have to find a clean solution to hide the first layout,
otherwise decorations will be floating around d forever...;)

Any idea?

data ToggleLayout a = TL Bool deriving (Read,Show)

instance LayoutCombinator ToggleLay a where
    chooser (TL b) = if b then DoFirst else DoSecond
    comboHandleMess (TL b) _ _ m
        | Just Togg <- fromMessage m = return $ TL (not b)
        | otherwise = return (TL b)

data ToggleLayoutMsg = Toggle deriving (Read,Show,Typeable)
instance Message ToggleLayoutMsg

toggle :: l1 a -> l2 a -> CombinedLayout ToggleLayout l1 l2 a
toggle = CombinedLayout (TL True)

to use as: toggle Full tabbed

Tue Jan 29 18:25:24 CET 2008  Andrea Rossato <andrea.rossato at unibz.it>
  * The start of a LayoutCombinator class with a CombinedLayout
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/x-darcs-patch
Size: 23789 bytes
Desc: A darcs patch for your repository!
Url : http://www.haskell.org/pipermail/xmonad/attachments/20080129/ef4f51d8/attachment-0001.bin

More information about the xmonad mailing list