Merge pull request #337 from slotThe/lazy-lifted-boolean-ops

Make `(<&&>)` and `(<||>)` lazy in their second argument
This commit is contained in:
slotThe 2021-10-17 10:14:02 +02:00 committed by GitHub
commit b5b95e27ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View File

@ -68,6 +68,11 @@
* Added `withUnfocused` function to `XMonad.Operations`, allowing for
`X` operations to be applied to unfocused windows.
* Made `(<&&>)` and `(<||>)` non-strict in their right operand; i.e.,
these operators now implement short-circuit evaluation so the right
operand is evaluated only if the left operand does not suffice to
determine the result.
## 0.15 (September 30, 2018)
* Reimplement `sendMessage` to deal properly with windowset changes made

View File

@ -61,11 +61,15 @@ infixr 3 <&&>, <||>
-- | '&&' lifted to a 'Monad'.
(<&&>) :: Monad m => m Bool -> m Bool -> m Bool
(<&&>) = liftM2 (&&)
(<&&>) x y = ifM x y (pure False)
-- | '||' lifted to a 'Monad'.
(<||>) :: Monad m => m Bool -> m Bool -> m Bool
(<||>) = liftM2 (||)
(<||>) x y = ifM x (pure True) y
-- | If-then-else lifted to a 'Monad'.
ifM :: Monad m => m Bool -> m a -> m a -> m a
ifM mb t f = mb >>= \b -> if b then t else f
-- | Return the window title.
title :: Query String