3

I am trying to add the docks command to my .xmonad config, but adding it results in a somewhat confusing type error:

Error detected while loading xmonad configuration file: /home/dan/.xmonad/xmonad.hs

xmonad.hs:11:11: error:
    • Couldn't match expected type ‘XConfig l0’
                  with actual type ‘xmonad-0.14.2@xmonad-0.14.2-50ceb56c2be27c58b715ff1418342ea50324c61ceef6f33afc6bf382abd08795:XMonad.Core.XConfig
                                      (xmonad-0.14.2@xmonad-0.14.2-50ceb56c2be27c58b715ff1418342ea50324c61ceef6f33afc6bf382abd08795:XMonad.Layout.Choose
                                         xmonad-0.14.2@xmonad-0.14.2-50ceb56c2be27c58b715ff1418342ea50324c61ceef6f33afc6bf382abd08795:XMonad.Layout.Tall
                                         (xmonad-0.14.2@xmonad-0.14.2-50ceb56c2be27c58b715ff1418342ea50324c61ceef6f33afc6bf382abd08795:XMonad.Layout.Choose
                                            (xmonad-0.14.2@xmonad-0.14.2-50ceb56c2be27c58b715ff1418342ea50324c61ceef6f33afc6bf382abd08795:XMonad.Layout.Mirror
                                               xmonad-0.14.2@xmonad-0.14.2-50ceb56c2be27c58b715ff1418342ea50324c61ceef6f33afc6bf382abd08795:XMonad.Layout.Tall)
                                            xmonad-0.14.2@xmonad-0.14.2-50ceb56c2be27c58b715ff1418342ea50324c61ceef6f33afc6bf382abd08795:XMonad.Layout.Full))’
      NB: ‘xmonad-0.14.2@xmonad-0.14.2-50ceb56c2be27c58b715ff1418342ea50324c61ceef6f33afc6bf382abd08795:XMonad.Core.XConfig’
            is defined in ‘XMonad.Core’
                in package ‘xmonad-0.14.2@xmonad-0.14.2-50ceb56c2be27c58b715ff1418342ea50324c61ceef6f33afc6bf382abd08795’
          ‘XConfig’
            is defined in ‘XMonad.Core’
                in package ‘xmonad-0.14.2@xmonad-0.14.2-8c611bf8742b1b94190ab2fa494cb2a1cd3f8666db2ba536c81ae848ea043a6b’
    • In the first argument of ‘xmonad’, namely ‘(docks def)’
      In the expression: xmonad (docks def)
      In an equation for ‘main’: main = xmonad (docks def)

Please check the file for errors.

Here is my config file:

import           XMonad
import           XMonad.Hooks.ManageDocks (docks)

main :: IO ()
main =
  xmonad (docks def)

I'm not sure what exactly has gone wrong here, and think perhaps I have messed something up during install.. though I'm not sure how to troubleshoot.


Output of ghc-pkg list xmonad:

/opt/ghc/8.0.2/lib/ghc-8.0.2/package.conf.d
    (no packages)
/home/dan/.ghc/x86_64-linux-8.0.2/package.conf.d
    (no packages)
Chris Stryczynski
  • 30,145
  • 48
  • 175
  • 286
danbroooks
  • 2,712
  • 5
  • 21
  • 43
  • It looks like there are somehow two different `xmonad` packages in scope. How have you installed `xmonad`? – Koterpillar Apr 20 '19 at 00:01
  • I have recently done `cabal new-install xmonad`, but looking through `history` I have previously installed `xmonad` using `apt-get`, removing `xmonad` through `apt-get remove` has removed the xmonad login option (in Ubuntu), though I can still run the xmonad command, still resulting in the same error – danbroooks Apr 20 '19 at 10:26
  • What does `ghc-pkg list xmonad` show? – Koterpillar Apr 20 '19 at 10:56
  • I've added that output to the bottom of the question – danbroooks Apr 20 '19 at 12:46

2 Answers2

1

This error indicates that your build somehow depended on two different xmonad Cabal packages. When compiling anything, GHC stores, along with the type name itself (e.g. Prelude.Maybe) the package it came from (in the case of Prelude, base). You can see a list of packages available to GHC with ghc-pkg list.

The error message says that docks produced a value of type XMonad.Core.XConfig from xmonad-0.14.2@xmonad-0.14.2-50ceb56c2be27c58b715ff1418342ea50324c61ceef6f33afc6bf382abd08795 package (I'll refer to it as "xmonad 50" further for brevity). Note that docks itself is part of the xmonad-contrib package. However, the value expected by xmonad is of type XMonad.Core.XConfig from xmonad-0.14.2@xmonad-0.14.2-8c611bf8742b1b94190ab2fa494cb2a1cd3f8666db2ba536c81ae848ea043a6b package ("xmonad 8" further on).

This is the dependency graph of your build:

  • your build
    • xmonad 8
    • xmonad-contrib
      • xmonad 50

Speculation of how this came to be:

  • You installed xmonad-contrib and/or xmonad somehow, either from your OS repositories or by compiling manually. Your package database now contains xmonad 50 and xmonad-contrib.
  • You installed xmonad again, and this created a different package version (xmonad 8). However, xmonad-contrib available to you is still from the earlier installation, compiled against xmonad 50.

This problem is known as Cabal Hell (another explanation).

What you can do next:

  • Check that you don't somehow have two GHC versions installed. /opt/ghc is a nonstandard installation path, there might be other versions in your distribution's standard path.
  • Investigate where the two xmonad libraries and one xmonad-contrib are installed. ghc-pkg list and ghc-pkg list --user might help here, or failing that, using strace or similar tools to see where xmonad looks while recompiling.
  • Remove and reinstall packages so that you only have one xmonad and one xmonad-contrib depending on that. If you found the extra versions in the previous step, you can try ghc-pkg unregister them, and if not, removing the full package database(s) and reinstalling the needed packages again (together!) can help.

In the future, try not to install packages related to XMonad from different sources, and if you want to use new-style Cabal builds, check a tutorial specifically about new-style builds and XMonad (I am not using that so unfortunately cannot suggest any.)

Koterpillar
  • 7,883
  • 2
  • 25
  • 41
-1

Your main function needs to be something like

main = do
  xmonad $ docks def