patches to use data-default

I noticed that there's a lot of places in xmonad and xmonad-contrib where we have manually-namespaced, monomorphic default values (especially for configurations and such things). The data-default package was designed for this, so I've drawn up a patch to use it. I've included two patch bundles, one for the xmonad repository, and one for the xmonad-contrib repository. (Technically, I have enough permissions to apply the xmonad-contrib ones myself; but I wanted to invite some review.) The bundle for -contrib includes three patches, in roughly increasing order of pervasiveness: 1. the minimal change to make things compile with the -core patch 2. a patch which eliminates all references to defaultConfig (including in the documentation) 3. a patch that uses data-default for things like defaultXPConfig, defaultPP, and similar things I've done my best to: * maintain backwards compatibility. Configs that use these symbols should generate a warning, but still work perfectly correctly. * ensure that all the places that used to export default values now also export "def", so that working configs can eliminate the warnings without changing their imports (or at worst change imports of defaultXPConfig, etc. to imports of def) Enjoy! ~d

This 1-patch bundle was just applied to http://code.haskell.org/xmonad:
20130528003531 Daniel Wagner

Hello Daniel, I like this on xmonad-contrib. I would suggest the name `default` instead of `def` though. What do you think about having Default instances for states? e.g. for XState and/or XPState. They would be considered to be the initial state of course.

On Wed, May 29, 2013 at 6:45 AM, Carlos López Camey
Hello Daniel, I like this on xmonad-contrib. I would suggest the name `default` instead of `def` though.
What do you think about having Default instances for states? e.g. for XState and/or XPState. They would be considered to be the initial state of course.
Hi Carlos, The reason data-default uses def is probably because default is a keyword in haskell. What's your expected use for a default XState? Those couldn't be the real initial state in most cases, since they depend on the corresponding defaultConfig / defaultXPConfig. -- Adam

On 28 May 2013 03:47, Daniel Wagner
I've done my best to: * maintain backwards compatibility. Configs that use these symbols should generate a warning, but still work perfectly correctly. * ensure that all the places that used to export default values now also export "def", so that working configs can eliminate the warnings without changing their imports (or at worst change imports of defaultXPConfig, etc. to imports of def)
Seems that you have forgot to fix the warnings that this introduces? Anyways I'm getting the below warning when building from darcs. XMonad/Core.hs:195:13:
Warning: This binding for `def' shadows the existing binding imported from `Data.Default' at XMonad/Core.hs:40:1-19
The affected line 195, is the userCodeDef seen below: -- | Execute the argument, catching all exceptions. Either this function
or
-- 'catchX' should be used at all callsites of user customized code.
userCode :: X a -> X (Maybe a) userCode a = catchX (Just `liftM` a) (return Nothing) -- | Same as userCode but with a default argument to return instead of using
-- Maybe, provided for convenience.
userCodeDef :: a -> X a -> X a userCodeDef def a = fromMaybe def `liftM` userCode a
Would it make sense to have -Werror turned on by default, such that xmonad always compiles without warnings? The reason why this is a problem is because I'm taking a new crack at fixing my updates to the old QC code such that it will compile against the darcs code instead of my own. When compiling the test code, -Werror is turned on, which prevents me from compiling right now. Obviously I have fixed this locally for now. -- Reenberg

On 2013-06-27 19:08, Jesper Reenberg wrote:
On 28 May 2013 03:47, Daniel Wagner
wrote: I've done my best to: * maintain backwards compatibility. Configs that use these symbols should generate a warning, but still work perfectly correctly. * ensure that all the places that used to export default values now also export "def", so that working configs can eliminate the warnings without changing their imports (or at worst change imports of defaultXPConfig, etc. to imports of def)
Seems that you have forgot to fix the warnings that this introduces?
I have sent a patch fixing this warning, but for whatever reason it hasn't been applied yet. You can find it in the xmonad@ archives. Cheers, ~d

Hi, I'm sending a patch that makes the latest version of xmonad-contrib
compile; it adds data-default in the cabal file and the necessary imports
of Data.Default.
Daniel, I also changed some def's to defaultConfig - I could not write an
instance Default of (XConfig anyLayout). I'm sorry if I spoiled any of your
code.
2013/6/27 Daniel Wagner
On 2013-06-27 19:08, Jesper Reenberg wrote:
On 28 May 2013 03:47, Daniel Wagner
wrote: I've done my best to:
* maintain backwards compatibility. Configs that use these symbols should generate a warning, but still work perfectly correctly. * ensure that all the places that used to export default values now also export "def", so that working configs can eliminate the warnings without changing their imports (or at worst change imports of defaultXPConfig, etc. to imports of def)
Seems that you have forgot to fix the warnings that this introduces?
I have sent a patch fixing this warning, but for whatever reason it hasn't been applied yet. You can find it in the xmonad@ archives.
Cheers, ~d
______________________________**_________________ xmonad mailing list xmonad@haskell.org http://www.haskell.org/**mailman/listinfo/xmonadhttp://www.haskell.org/mailman/listinfo/xmonad

Hi Carlos. I'm sorry you had trouble building xmonad-contrib. Did you make sure to darcs pull and cabal install in your xmonad library directory to upgrade it? If you do this, none of the changes in this patch should be necessary. This also provides an instance of Default for XConfig, though as you observed it is not so polymorphic as to give one for (XConfig a) -- only for XConfig TheTypeCorrespondingToTheDefaultLayout. ~d On 2013-07-20 16:11, Carlos López-Camey wrote:
Hi, I'm sending a patch that makes the latest version of xmonad-contrib compile; it adds data-default in the cabal file and the necessary imports of Data.Default.
Daniel, I also changed some def's to defaultConfig - I could not write an instance Default of (XConfig anyLayout). I'm sorry if I spoiled any of your code.
2013/6/27 Daniel Wagner
On 2013-06-27 19:08, Jesper Reenberg wrote: On 28 May 2013 03:47, Daniel Wagner
wrote: I've done my best to: * maintain backwards compatibility. Configs that use these symbols should generate a warning, but still work perfectly correctly. * ensure that all the places that used to export default values now also export "def", so that working configs can eliminate the warnings without changing their imports (or at worst change imports of defaultXPConfig, etc. to imports of def)
Seems that you have forgot to fix the warnings that this introduces?
I have sent a patch fixing this warning, but for whatever reason it hasn't been applied yet. You can find it in the xmonad@ archives.
Cheers, ~d
_______________________________________________ xmonad mailing list xmonad@haskell.org http://www.haskell.org/mailman/listinfo/xmonad [1]
Links: ------ [1] http://www.haskell.org/mailman/listinfo/xmonad
_______________________________________________ xmonad mailing list xmonad@haskell.org http://www.haskell.org/mailman/listinfo/xmonad

On Sat, Jul 20, 2013 at 6:58 PM, Daniel Wagner
Did you make sure to darcs pull and cabal install in your xmonad library directory to upgrade it? If you do this, none of the changes in this patch should be necessary.
I've pushed patches raising the version numbers of xmonad and xmonad-contrib, which should prevent this issue from happening again. -- Adam
participants (7)
-
adam vogt
-
Carlos López Camey
-
Carlos López-Camey
-
Daniel Wagner
-
Daniel Wagner
-
darcswatch@nomeata.de
-
Jesper Reenberg