Xmonad 中的用户状态
User state in Xmonad
是否可以在 Xmonad 中拥有用户状态?
我现在正在使用全局变量,但我想知道在 Xmonad 中是否有正确的方法来执行此操作。 (例如:在 parsec 中,有一个用户状态,所以您可以使用 Parser TYPE ...
,其中 TYPE 是用户状态的类型,可以使用 getState、putState 和 modifyState 查询。)
Xmonad 中的布局状态可以是 specified/modified 在 config.hs module, but Xmonad has also got extensible states that you can implement. I would recommend you look at both. The docs on the Haskell Extensible States 中将模块列为 'unstable' 但我认为自从该文档更新后(大约三年?)
[示例] 代码如下所示:
{-# LANGUAGE DeriveDataTypeable #-}
import qualified XMonad.Util.ExtensibleState as XS
data ListStorage = ListStorage [Integer] deriving Typeable
instance ExtensionClass ListStorage where
initialValue = ListStorage []
.. XS.put (ListStorage [23,42])
(e.g.) put :: ExtensionClass a => a -> X ()
是否可以在 Xmonad 中拥有用户状态?
我现在正在使用全局变量,但我想知道在 Xmonad 中是否有正确的方法来执行此操作。 (例如:在 parsec 中,有一个用户状态,所以您可以使用 Parser TYPE ...
,其中 TYPE 是用户状态的类型,可以使用 getState、putState 和 modifyState 查询。)
Xmonad 中的布局状态可以是 specified/modified 在 config.hs module, but Xmonad has also got extensible states that you can implement. I would recommend you look at both. The docs on the Haskell Extensible States 中将模块列为 'unstable' 但我认为自从该文档更新后(大约三年?)
[示例] 代码如下所示:
{-# LANGUAGE DeriveDataTypeable #-}
import qualified XMonad.Util.ExtensibleState as XS
data ListStorage = ListStorage [Integer] deriving Typeable
instance ExtensionClass ListStorage where
initialValue = ListStorage []
.. XS.put (ListStorage [23,42])
(e.g.) put :: ExtensionClass a => a -> X ()