mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 11:30:22 -07:00
X.U.ActionQueue: Separate ExtState and ExtConf data types
Using the same type for both is confusing and requires a bogus Semigroup instance.
This commit is contained in:
parent
50527a4613
commit
2b5d2c5ab8
@ -55,27 +55,17 @@ import Data.Sequence (Seq (..), ViewL (..), viewl, (|>))
|
|||||||
--
|
--
|
||||||
|
|
||||||
newtype ActionQueue = ActionQueue (Seq (X ()))
|
newtype ActionQueue = ActionQueue (Seq (X ()))
|
||||||
deriving newtype (Semigroup)
|
|
||||||
|
|
||||||
-- NOTE: The 'Semigroup' instance is technically wrong for a queue
|
|
||||||
-- (simply appending two queues together). However, since these are
|
|
||||||
-- only needed for essentially the unit element and multiplication with
|
|
||||||
-- the unit, this does not seem like a big deal.
|
|
||||||
--
|
|
||||||
-- Indeed, since 'ActionQueue' is exported as an abstract type, there is
|
|
||||||
-- no way to build up a queue outside os using 'enqueue', meaning users
|
|
||||||
-- can't abuse these.
|
|
||||||
|
|
||||||
instance ExtensionClass ActionQueue where
|
instance ExtensionClass ActionQueue where
|
||||||
initialValue = emptyQueue
|
initialValue = ActionQueue mempty
|
||||||
|
|
||||||
emptyQueue :: ActionQueue
|
newtype ActionQueueHooked = ActionQueueHooked ()
|
||||||
emptyQueue = ActionQueue mempty
|
deriving newtype (Semigroup)
|
||||||
|
|
||||||
-- | Every time the @logHook@ runs, execute all actions in the queue.
|
-- | Every time the @logHook@ runs, execute all actions in the queue.
|
||||||
actionQueue :: XConfig l -> XConfig l
|
actionQueue :: XConfig l -> XConfig l
|
||||||
actionQueue = XC.once (\cfg -> cfg{ logHook = logHook cfg <> exequeue })
|
actionQueue = XC.once (\cfg -> cfg{ logHook = logHook cfg <> exequeue })
|
||||||
emptyQueue
|
ActionQueueHooked
|
||||||
|
|
||||||
-- | Enqueue an action.
|
-- | Enqueue an action.
|
||||||
enqueue :: X () -> X ()
|
enqueue :: X () -> X ()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user