From 702686e5dadd21290c3213477dab5ff9c041891f Mon Sep 17 00:00:00 2001 From: Brandon S Allbery KF8NH Date: Thu, 24 Feb 2011 01:30:21 +0100 Subject: Generalize types of ManageHook functions, so they can be reused Ignore-this: 2328f5a2ca705279ba8ae1fe4decd03e darcs-hash:20110224003021-8238f-5f37da8419ee25376f6c48da67b2ae781e89f4dd --- XMonad/ManageHook.hs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'XMonad') diff --git a/XMonad/ManageHook.hs b/XMonad/ManageHook.hs index 945e40b..b96933e 100644 --- a/XMonad/ManageHook.hs +++ b/XMonad/ManageHook.hs @@ -34,22 +34,23 @@ liftX :: X a -> Query a liftX = Query . lift -- | The identity hook that returns the WindowSet unchanged. -idHook :: ManageHook -idHook = doF id +idHook :: Monoid m => m +idHook = mempty -- | Infix 'mappend'. Compose two 'ManageHook' from right to left. (<+>) :: Monoid m => m -> m -> m (<+>) = mappend -- | Compose the list of 'ManageHook's. -composeAll :: [ManageHook] -> ManageHook +composeAll :: Monoid m => [m] -> m composeAll = mconcat infix 0 --> -- | @p --> x@. If @p@ returns 'True', execute the 'ManageHook'. -(-->) :: Query Bool -> ManageHook -> ManageHook -p --> f = p >>= \b -> if b then f else mempty +-- (-->) :: Monoid m => Query Bool -> Query m -> Query m +(-->) :: (Monad m, Monoid a) => m Bool -> m a -> m a +p --> f = p >>= \b -> if b then f else return mempty -- | @q =? x@. if the result of @q@ equals @x@, return 'True'. (=?) :: Eq a => Query a -> a -> Query Bool @@ -101,7 +102,7 @@ getStringProperty d w p = do return $ fmap (map (toEnum . fromIntegral)) md -- | Modify the 'WindowSet' with a pure function. -doF :: (WindowSet -> WindowSet) -> ManageHook +doF :: (s -> s) -> Query (Endo s) doF = return . Endo -- | Move the window to the floating layer. -- cgit v1.2.3