
On Fri, Oct 12, 2007 at 01:06:22AM +0200, mail@joachim-breitner.de wrote:
Sat Oct 6 18:03:24 CEST 2007 mail@joachim-breitner.de * ManageHook list interface This patch implements the proposed manageLog interface outlined in http://code.google.com/p/xmonad/issues/detail?id=54
Note that all the Data.Monoid stuff is just to avoid writing foldl (.) id as mconcat. Maybe foldl (.) id is nicer in this case.
I'm not sure if I put the ManageHook type declaration in the right spot.
I did not adjust any plugins to the new interface, although the recently commited ManageDocks.hs by chance already had this interface :-)
The Config.hs could probably need some example, as soon as some plugins use this interface
-- Add hooks from imported extensions, e.g. manageHooks = [ floatGimp, manageDocksHook ]
hunk ./Operations.hs 68 - - n <- fmap (fromMaybe "") $ io $ fetchName d w - - (ClassHint rn rc) <- io $ getClassHint d w - - g <- manageHook w n rn rc + -- Unfortunately, we don't have + -- > instance Monoid (a -> a) + -- and have to wrap it with Endo. Or we just use + -- > fold (.) id + -- instead of + -- (appEndo . mconcat . map (Endo)) + g <- (appEndo . mconcat . map (Endo)) `fmap` mapM ($w) manageHooks
Why not put this code into a module? There's no reason not to do so, that I'm aware of. If there *is* a reason this should be in core, perhaps you could tell us.
+-- ------------------------------------------------------------------ +-- | +-- Manage Hook type +-- This is the type for hooks that want to run when a window is first managed. +-- Hooks can examine the Window and do an appropriate action. +-- If they do not apply, they should return id. +-- +type ManageHook = Window -> X (WindowSet -> WindowSet)
Why not use the more user-friendly type that's already in place? type ManageHook :: Window -- ^ the new window to manage -> String -- ^ window title -> String -- ^ window resource name -> String -- ^ window resource class -> X (WindowSet -> WindowSet) It's not really any more difficult to use, and is just plain more powerful and easy to use. The folks who want to write two-line functions can do so beautifully and easily (and relatively readably). We could extend this a bit with something like data WindowInfo = WindowInfo { w :: Window, title :: String, ... } which might make the code even more readable, but I don't see any reason to clutter Config with actual monadic calls to discover the window's title (not to mention the inelegance of doing so N times for N hooks). -- David Roundy Department of Physics Oregon State University