mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-09-01 11:53:48 -07:00
X.U.ExtensibleConf: Add high-level idioms for non-Semigroup, but Default types
For configuration values that don't compose well using a Semigroup instance, provide a high-level API allowing arbitrary modification of the value, taking its Default if absent. This API is only usable for separate configuration data and cannot be used to guard addition of hook using `once`.
This commit is contained in:
@@ -21,11 +21,21 @@ spec = do
|
||||
specify "lookup @() . add @String . add @[Int]" $
|
||||
XC.lookup (XC.add "a" (XC.add [1 :: Int] def)) `shouldBe` (Nothing :: Maybe ())
|
||||
|
||||
specify "once" $
|
||||
borderWidth (XC.once incBorderWidth "a" def) `shouldBe` succ (borderWidth def)
|
||||
specify "once . once" $
|
||||
borderWidth (XC.once incBorderWidth "b" (XC.once incBorderWidth "a" def))
|
||||
`shouldBe` succ (borderWidth def)
|
||||
specify "once" $ do
|
||||
let c = XC.once incBorderWidth "a" def
|
||||
borderWidth c `shouldBe` succ (borderWidth def)
|
||||
XC.lookup c `shouldBe` Just "a"
|
||||
specify "once . once" $ do
|
||||
let c = XC.once incBorderWidth "b" (XC.once incBorderWidth "a" def)
|
||||
borderWidth c `shouldBe` succ (borderWidth def)
|
||||
XC.lookup c `shouldBe` Just "ab"
|
||||
|
||||
specify "modifyDef" $ do
|
||||
let c = XC.modifyDef (<> "a") def
|
||||
XC.lookup c `shouldBe` Just "a"
|
||||
specify "modifyDef . modifyDef" $ do
|
||||
let c = XC.modifyDef (<> "b") (XC.modifyDef (<> "a") def)
|
||||
XC.lookup c `shouldBe` Just "ab"
|
||||
|
||||
incBorderWidth :: XConfig l -> XConfig l
|
||||
incBorderWidth c = c{ borderWidth = succ (borderWidth c) }
|
||||
|
Reference in New Issue
Block a user