使用不正确的 Data.Map 时出现 XMonad 编译错误

发布于 2024-11-05 19:23:26 字数 2511 浏览 0 评论 0原文

所以我坐在这里为自己编译 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

谜兔 2024-11-12 19:23:26

看起来您可能安装了两个版本的容器。您可以通过以下方式确认这一点:

$ ghc-pkg list containers
/home/dons/lib/ghc-7.0.3/package.conf.d
    containers-0.4.0.0
/home/dons/.ghc/x86_64-linux-7.0.3/package.conf.d
    containers-0.3.0.0

虽然这本身没问题,但当您的某些库针对一个版本编译,而另一些库针对另一个版本编译时,就会出现问题。当这些库依次汇集在一起​​时(例如通过 xmonad),您会收到此类类型错误 - 钻石依赖性问题。

解决方案是删除一个容器版本,并重新编译所有随后损坏的库,这样您就拥有了一个干净的工具链。

Looks like you might have two versions of containers installed. You can confirm this with:

$ ghc-pkg list containers
/home/dons/lib/ghc-7.0.3/package.conf.d
    containers-0.4.0.0
/home/dons/.ghc/x86_64-linux-7.0.3/package.conf.d
    containers-0.3.0.0

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.

自控 2024-11-12 19:23:26

您还可以使用以下方法隐藏这些包之一:

ghc-pkg hide containers-0.3.0.0

You could also hide one of those packages with:

ghc-pkg hide containers-0.3.0.0
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文