使用不正确的 Data.Map 时出现 XMonad 编译错误
所以我坐在这里为自己编译 XMonad,因为我不喜欢我的包管理器提供 0.9.1 版本,而喜欢 0.9.2。 是 XMonad 本身的编译成功,但当 xmonad 尝试解析我的配置文件时,我收到一个奇怪的错误:
xmonad.hs:254:15:
Couldn't match expected type `containers-0.3.0.0:Data.Map.Map
(ButtonMask, KeySym) (X ())'
against inferred type `M.Map (KeyMask, KeySym) (X ())'
In the `keys' field of a record
In the first argument of `xmobar', namely
`myBaseConfig
{modMask = myModMask,
workspaces = withScreens nScreens myWorkspaces,
layoutHook = myLayoutHook nScreens, manageHook = myManageHook,
borderWidth = myBorderWidth,
normalBorderColor = myNormalBorderColor,
focusedBorderColor = myFocusedBorderColor, keys = myKeys,
mouseBindings = myMouseBindings, logHook = myLogHook}'
In the second argument of `(=<<)', namely
`xmobar
(myBaseConfig
{modMask = myModMask,
workspaces = withScreens nScreens myWorkspaces,
layoutHook = myLayoutHook nScreens, manageHook = myManageHook,
borderWidth = myBorderWidth,
normalBorderColor = myNormalBorderColor,
focusedBorderColor = myFocusedBorderColor, keys = myKeys,
mouseBindings = myMouseBindings, logHook = myLogHook})'
我能够追踪问题的原因,并显示在下面的 ghci 会话中:
GHCi, version 6.12.3: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
$ :m xmonad
syntax: :module [+/-] [*]M1 ... [*]Mn
$ :m XMonad
$ :t XConfig
XConfig
:: String
-> String
-> String
-> l Window
-> ManageHook
-> (Event -> X Data.Monoid.All)
-> [String]
-> KeyMask
-> KeyMask
-> (XConfig Layout
-> containers-0.3.0.0:Data.Map.Map (ButtonMask, KeySym) (X ()))
-> (XConfig Layout
-> containers-0.3.0.0:Data.Map.Map
(ButtonMask, Button) (Window -> X ()))
-> Dimension
-> X ()
-> X ()
-> Bool
-> XConfig l
$
Leaving GHCi.
当前的问题 似乎是这一行:
-> containers-0.3.0.0:Data.Map.Map (ButtonMask, KeySym) (X ()))
我本以为它可能会说:
-> M.Map (ButtonMask, KeySym) (X ()))
我只是想知道我是否正确诊断了问题,如果是,我能做些什么来解决它?
So I'm sitting here compiling XMonad for myself because I do not like being provided with version 0.9.1 by my package manager and like 0.9.2. The current problem is that the compilation of XMonad itself succeeds but then I get a weird error when xmonad tries to parse my config file:
xmonad.hs:254:15:
Couldn't match expected type `containers-0.3.0.0:Data.Map.Map
(ButtonMask, KeySym) (X ())'
against inferred type `M.Map (KeyMask, KeySym) (X ())'
In the `keys' field of a record
In the first argument of `xmobar', namely
`myBaseConfig
{modMask = myModMask,
workspaces = withScreens nScreens myWorkspaces,
layoutHook = myLayoutHook nScreens, manageHook = myManageHook,
borderWidth = myBorderWidth,
normalBorderColor = myNormalBorderColor,
focusedBorderColor = myFocusedBorderColor, keys = myKeys,
mouseBindings = myMouseBindings, logHook = myLogHook}'
In the second argument of `(=<<)', namely
`xmobar
(myBaseConfig
{modMask = myModMask,
workspaces = withScreens nScreens myWorkspaces,
layoutHook = myLayoutHook nScreens, manageHook = myManageHook,
borderWidth = myBorderWidth,
normalBorderColor = myNormalBorderColor,
focusedBorderColor = myFocusedBorderColor, keys = myKeys,
mouseBindings = myMouseBindings, logHook = myLogHook})'
I was able to trace the cause of the problem down and it is displayed in this ghci session below:
GHCi, version 6.12.3: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
$ :m xmonad
syntax: :module [+/-] [*]M1 ... [*]Mn
$ :m XMonad
$ :t XConfig
XConfig
:: String
-> String
-> String
-> l Window
-> ManageHook
-> (Event -> X Data.Monoid.All)
-> [String]
-> KeyMask
-> KeyMask
-> (XConfig Layout
-> containers-0.3.0.0:Data.Map.Map (ButtonMask, KeySym) (X ()))
-> (XConfig Layout
-> containers-0.3.0.0:Data.Map.Map
(ButtonMask, Button) (Window -> X ()))
-> Dimension
-> X ()
-> X ()
-> Bool
-> XConfig l
$
Leaving GHCi.
The problem seems to be this line:
-> containers-0.3.0.0:Data.Map.Map (ButtonMask, KeySym) (X ()))
I would have thought that it might have said:
-> M.Map (ButtonMask, KeySym) (X ()))
I am just wondering if I diagnosed the problem correctly and if so, what can I do to fix it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看起来您可能安装了两个版本的
容器
。您可以通过以下方式确认这一点:虽然这本身没问题,但当您的某些库针对一个版本编译,而另一些库针对另一个版本编译时,就会出现问题。当这些库依次汇集在一起时(例如通过 xmonad),您会收到此类类型错误 - 钻石依赖性问题。
解决方案是删除一个
容器
版本,并重新编译所有随后损坏的库,这样您就拥有了一个干净的工具链。Looks like you might have two versions of
containers
installed. You can confirm this with:while that by itself is fine, the problems occur when you have some of your libraries compiled against one version, and some against another. When those libraries in turn are brought together, e.g. by xmonad, you get type errors of this sort -- the diamond dependency problem.
A solution is to remove one of the versions of
containers
, and recompile any libs that then break, so you have a clean toolchain.您还可以使用以下方法隐藏这些包之一:
You could also hide one of those packages with: