4

This may be borderline between here an SO since a lot of the question is about haskell programming. Yet, in the end, it is a configuration issue.

Background and research

Since 0.12 Xmonad throws this warning (several times) in 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."

And it works, it is just a warning. Yet, I'd like to understand what is causing the warning (I'm trying to understand it and failing at it for several hours already). By the deprecation description you'd guess that XMonad.Config is not using the definition of Default from Data.Default, but that is not the case. Looking at the code of XMonad.Config you see at the beginning the import:

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

And Data.Default is definitely there. Then defaultConfig (still inside Xmonad.Config) is defined as:

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

So defaultConfig should be using Data.Default, and I am the one doing something wrong, probably.


Solution attempts

My minimal configuration (xmonad.hs) that is throwing the warning is:

import XMonad

main = xmonad defaultConfig { terminal = "urxvt" }

(My full xmonad configuration is huge, the above is just a minimal config that replicates the warning.)

I tried:

import Data.Default
import XMonad

main = xmonad defaultConfig { terminal = "urxvt" }

But the warning remains. I could use main = xmonad XConfig {} and then enumerate every configuration option, but that would be copying 90% of XMonad.Config into my own xmonad.hs.


Question

What am I doing wrong? How do I force the use of Data.Default? Did I understood the deprecation warning correctly in the first place?

8

You don't need import import Data.Default

this is imported in XMonad itself

only one change is needed:

import XMonad
main = xmonad defaultConfig { terminal = "urxvt" }

to

import XMonad
main = xmonad def { terminal = "urxvt" }
  • It works! I can't believe it was that stupid a mistake that i did. In the end I used import qualified XMonad.Config as DefConfig and then DefConfig.def in every place with defaultConfig. Many thanks. – grochmal Jan 12 '17 at 0:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.