Xmonad
Xmonad 預設棄用:什麼是未來證明配置?
這可能是SO之間的界限,因為很多問題都是關於haskell程式的。然而,歸根結底,這是一個配置問題。
背景與研究
由於 0.12 Xmonad 在 xmonad.errors 中拋出此警告(多次):
xmonad.hs:15:14: warning: [-Wdeprecations] In the use of ‘defaultConfig’ (imported from XMonad, but defined in XMonad.Config): Deprecated: "Use def (from Data.Default, and re-exported by XMonad and XMonad.Config) instead."
它有效,這只是一個警告。然而,我想了解是什麼導致了警告(我試圖理解它並且已經失敗了幾個小時)。根據棄用描述,您可能會猜測它
XMonad.Config
沒有使用Default
from的定義Data.Default
,但事實並非如此。XMonad.Config
查看您在導入開始時看到的程式碼:import XMonad.Core as XMonad hiding (workspaces,manageHook,keys,logHook,startupHook,borderWidth,mouseBindings ,layoutHook,modMask,terminal,normalBorderColor,focusedBorderColor,focusFollowsMouse ,handleEventHook,clickJustFocuses,rootMask,clientMask) import qualified XMonad.Core as XMonad (workspaces,manageHook,keys,logHook,startupHook,borderWidth,mouseBindings ,layoutHook,modMask,terminal,normalBorderColor,focusedBorderColor,focusFollowsMouse ,handleEventHook,clickJustFocuses,rootMask,clientMask) import XMonad.Layout import XMonad.Operations import XMonad.ManageHook import qualified XMonad.StackSet as W import Data.Bits ((.|.)) import Data.Default import Data.Monoid import qualified Data.Map as M import System.Exit import Graphics.X11.Xlib import Graphics.X11.Xlib.Extras
並且
Data.Default
肯定存在。然後defaultConfig
(仍在內部Xmonad.Config
)定義為:instance (a ~ Choose Tall (Choose (Mirror Tall) Full)) => Default (XConfig a) where def = XConfig { XMonad.borderWidth = borderWidth ... ... ... ... ... ... , XMonad.rootMask = rootMask , XMonad.handleExtraArgs = \ xs theConf -> case xs of [] -> return theConf _ -> fail ("unrecognized flags:" ++ show xs) } -- | The default set of configuration values itself {-# DEPRECATED defaultConfig "Use def (from Data.Default, and re-exported by XMonad and XMonad.Config) instead." #-} defaultConfig :: XConfig (Choose Tall (Choose (Mirror Tall) Full)) defaultConfig = def
所以
defaultConfig
應該使用Data.Default
,我可能是做錯事的人。解決方案嘗試
我發出警告的最小配置(
xmonad.hs
)是:import XMonad main = xmonad defaultConfig { terminal = "urxvt" }
(我的完整 xmonad 配置很大,上面只是複制警告的最小配置。)
我試過:
import Data.Default import XMonad main = xmonad defaultConfig { terminal = "urxvt" }
但警告仍然存在。我可以使用
main = xmonad XConfig {}
然後列舉每個配置選項,但這會將 90% 的內容複製XMonad.Config
到我自己的xmonad.hs
.問題
我究竟做錯了什麼?我如何強制使用
Data.Default
?我是否首先正確理解了棄用警告?
你不需要導入
import Data.Default
這是在 XMonad 本身中導入的
只需進行一項更改:
import XMonad main = xmonad defaultConfig { terminal = "urxvt" }
到
import XMonad main = xmonad def { terminal = "urxvt" }