mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-08-15 20:23:55 -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
|
-- | Like 'workspaceHistoryHook', but with the ability to exclude
|
||||||
-- certain workspaces.
|
-- certain workspaces.
|
||||||
workspaceHistoryHookExclude :: [WorkspaceId] -> X ()
|
workspaceHistoryHookExclude :: [WorkspaceId] -> X ()
|
||||||
workspaceHistoryHookExclude ws =
|
workspaceHistoryHookExclude ws = do
|
||||||
gets windowset >>= XS.modify . updateLastActiveOnEachScreenExclude ws
|
s <- gets windowset
|
||||||
|
let update' a = force (updateLastActiveOnEachScreenExclude ws s a)
|
||||||
|
XS.modify' update'
|
||||||
|
|
||||||
workspaceHistoryWithScreen :: X [(ScreenId, WorkspaceId)]
|
workspaceHistoryWithScreen :: X [(ScreenId, WorkspaceId)]
|
||||||
workspaceHistoryWithScreen = XS.gets history
|
workspaceHistoryWithScreen = XS.gets history
|
||||||
|
@@ -20,6 +20,7 @@ module XMonad.Util.ExtensibleState (
|
|||||||
-- $usage
|
-- $usage
|
||||||
put
|
put
|
||||||
, modify
|
, modify
|
||||||
|
, modify'
|
||||||
, remove
|
, remove
|
||||||
, get
|
, get
|
||||||
, gets
|
, gets
|
||||||
@@ -90,6 +91,11 @@ modifyStateExts f = State.modify $ \st -> st { extensibleState = f (extensibleSt
|
|||||||
modify :: (ExtensionClass a, XLike m) => (a -> a) -> m ()
|
modify :: (ExtensionClass a, XLike m) => (a -> a) -> m ()
|
||||||
modify f = put . f =<< get
|
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
|
-- | 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
|
-- type will be overwritten. (More precisely: A value whose string representation of its type
|
||||||
-- is equal to the new one's)
|
-- is equal to the new one's)
|
||||||
|
Reference in New Issue
Block a user