mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-07-31 04:01:51 -07:00
Add a modify' function on extensible state
This commit is contained in:
@@ -77,8 +77,10 @@ workspaceHistoryHook = gets windowset >>= (XS.modify . updateLastActiveOnEachScr
|
||||
-- | Like 'workspaceHistoryHook', but with the ability to exclude
|
||||
-- certain workspaces.
|
||||
workspaceHistoryHookExclude :: [WorkspaceId] -> X ()
|
||||
workspaceHistoryHookExclude ws =
|
||||
gets windowset >>= XS.modify . updateLastActiveOnEachScreenExclude ws
|
||||
workspaceHistoryHookExclude ws = do
|
||||
s <- gets windowset
|
||||
let update' a = force (updateLastActiveOnEachScreenExclude ws s a)
|
||||
XS.modify' update'
|
||||
|
||||
workspaceHistoryWithScreen :: X [(ScreenId, WorkspaceId)]
|
||||
workspaceHistoryWithScreen = XS.gets history
|
||||
|
@@ -20,6 +20,7 @@ module XMonad.Util.ExtensibleState (
|
||||
-- $usage
|
||||
put
|
||||
, modify
|
||||
, modify'
|
||||
, remove
|
||||
, get
|
||||
, gets
|
||||
@@ -90,6 +91,11 @@ modifyStateExts f = State.modify $ \st -> st { extensibleState = f (extensibleSt
|
||||
modify :: (ExtensionClass a, XLike m) => (a -> a) -> m ()
|
||||
modify f = put . f =<< get
|
||||
|
||||
-- | Like @modify@ but the result value is applied strictly in respect to
|
||||
-- the monadic environment.
|
||||
modify' :: (ExtensionClass a, XLike m) => (a -> a) -> m ()
|
||||
modify' f = (\a -> let res = f a in res `seq` put res) =<< get
|
||||
|
||||
-- | Add a value to the extensible state field. A previously stored value with the same
|
||||
-- type will be overwritten. (More precisely: A value whose string representation of its type
|
||||
-- is equal to the new one's)
|
||||
|
Reference in New Issue
Block a user