Add 'and' and 'or' functions to ManageHook.

This commit is contained in:
Spencer Janssen 2007-11-21 10:46:13 +00:00
parent c95b8d9160
commit 1ab1d729a0

View File

@ -49,6 +49,16 @@ p --> f = p >>= \b -> if b then f else mempty
(=?) :: Eq a => Query a -> a -> Query Bool
q =? x = fmap (== x) q
infixr 3 <&&>, <||>
-- | 'p <&&> q'. '&&' lifted to a Monad.
(<&&>) :: Monad m => m Bool -> m Bool -> m Bool
(<&&>) = liftM2 (&&)
-- | 'p <||> q'. '||' lifted to a Monad.
(<||>) :: Monad m => m Bool -> m Bool -> m Bool
(<||>) = liftM2 (||)
-- | Queries that return the window title, resource, or class.
title, resource, className :: Query String
title = ask >>= (\w -> liftX $ withDisplay $ \d -> fmap (fromMaybe "") $ io $ fetchName d w)