Haskell 变量不在范围内
Haskell Variable not in scope
我正在配置我的 xmonad 文件以根据 https://hackage.haskell.org/package/xmonad-contrib-0.16/docs/XMonad-Hooks-DynamicLog.html#v:ppOutput
上的文档将 Stdout 发送到 SpawnPipe
这是我到目前为止的代码...我确定我只是缺少一种将 h 传递给 myLogHook 函数的方法! - 感谢您的帮助。
myLogHook = dynamicLogWithPP $ def { ppOutput = hPutStrLn h }
main = do
h <- spawnPipe "xmobar ~/.xmobar/.xmobarrc"
xmonad $ docks defaults
defaults = def {
-- simple stuff
terminal = myTerminal,
focusFollowsMouse = myFocusFollowsMouse,
clickJustFocuses = myClickJustFocuses,
borderWidth = myBorderWidth,
modMask = myModMask,
workspaces = myWorkspaces,
normalBorderColor = myNormalBorderColor,
focusedBorderColor = myFocusedBorderColor,
-- key bindings
keys = myKeys,
mouseBindings = myMouseBindings,
-- hooks, layouts
layoutHook = myLayout,
manageHook = myManageHook,
handleEventHook = myEventHook,
logHook = myLogHook,
startupHook = myStartupHook
}
首先,将myLogHook
改为句柄作为参数:
import System.IO
import XMonad
myLogHook :: Handle -> X ()
myLogHook h = dynamicLogWithPP $ def { ppOutput = hPutStrLn h }
然后,将其传递给钩子并从默认值中删除它:
main = do
h <- spawnPipe "xmobar ~/.xmobar/.xmobarrc"
xmonad $ docks $ defaults {
logHook = myLogHook h
}
defaults = def {
-- some stuff
logHook = return ()
-- more stuff
}
默认后的{}
基本覆盖属性
我正在配置我的 xmonad 文件以根据 https://hackage.haskell.org/package/xmonad-contrib-0.16/docs/XMonad-Hooks-DynamicLog.html#v:ppOutput
上的文档将 Stdout 发送到 SpawnPipe这是我到目前为止的代码...我确定我只是缺少一种将 h 传递给 myLogHook 函数的方法! - 感谢您的帮助。
myLogHook = dynamicLogWithPP $ def { ppOutput = hPutStrLn h }
main = do
h <- spawnPipe "xmobar ~/.xmobar/.xmobarrc"
xmonad $ docks defaults
defaults = def {
-- simple stuff
terminal = myTerminal,
focusFollowsMouse = myFocusFollowsMouse,
clickJustFocuses = myClickJustFocuses,
borderWidth = myBorderWidth,
modMask = myModMask,
workspaces = myWorkspaces,
normalBorderColor = myNormalBorderColor,
focusedBorderColor = myFocusedBorderColor,
-- key bindings
keys = myKeys,
mouseBindings = myMouseBindings,
-- hooks, layouts
layoutHook = myLayout,
manageHook = myManageHook,
handleEventHook = myEventHook,
logHook = myLogHook,
startupHook = myStartupHook
}
首先,将myLogHook
改为句柄作为参数:
import System.IO
import XMonad
myLogHook :: Handle -> X ()
myLogHook h = dynamicLogWithPP $ def { ppOutput = hPutStrLn h }
然后,将其传递给钩子并从默认值中删除它:
main = do
h <- spawnPipe "xmobar ~/.xmobar/.xmobarrc"
xmonad $ docks $ defaults {
logHook = myLogHook h
}
defaults = def {
-- some stuff
logHook = return ()
-- more stuff
}
默认后的{}
基本覆盖属性