From 3dbdc5115863cdf383c60a3b9980b9766de88e5b Mon Sep 17 00:00:00 2001 From: Tomas Janousek Date: Sun, 17 Oct 2021 22:01:26 +0100 Subject: [PATCH] X.U.ExtensibleConf: Perform 'add' before modifying in once(M) This better matches the documentation. It is still, however, considered bad practice to rely on the order of these operations. `f` isn't meant to touch any extensible configuration. If it happens to do so anyway, it no longer loops. :-) --- XMonad/Util/ExtensibleConf.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/XMonad/Util/ExtensibleConf.hs b/XMonad/Util/ExtensibleConf.hs index e51b9c47..e64832e0 100644 --- a/XMonad/Util/ExtensibleConf.hs +++ b/XMonad/Util/ExtensibleConf.hs @@ -117,7 +117,7 @@ once :: forall a l. (Semigroup a, Typeable a) => (XConfig l -> XConfig l) -- ^ 'XConfig' modification done only once -> a -- ^ configuration to add -> XConfig l -> XConfig l -once f x c = add x $ maybe f (const id) (lookup @a c) c +once f x c = maybe f (const id) (lookup @a c) $ add x c -- | Config-time: Applicative (monadic) variant of 'once', useful if the -- 'XConfig' modification needs to do some 'IO' (e.g. create an @@ -126,4 +126,4 @@ onceM :: forall a l m. (Applicative m, Semigroup a, Typeable a) => (XConfig l -> m (XConfig l)) -- ^ 'XConfig' modification done only once -> a -- ^ configuration to add -> XConfig l -> m (XConfig l) -onceM f x c = add x <$> maybe f (const pure) (lookup @a c) c +onceM f x c = maybe f (const pure) (lookup @a c) $ add x c