patches to use data-default

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

patches to use data-default

wagnerdm@seas.upenn.edu
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
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: data-default-xmonad.dpatch
URL: <http://www.haskell.org/pipermail/xmonad/attachments/20130527/50c75205/attachment-0001.txt>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: data-default-xmonad-contrib.dpatch
URL: <http://www.haskell.org/pipermail/xmonad/attachments/20130527/50c75205/attachment-0001.asc>

Reply | Threaded
Open this post in threaded view
|

Applied: patches to use data-default

darcswatch@nomeata.de
This 1-patch bundle was just applied to http://code.haskell.org/xmonad:

20130528003531  Daniel Wagner <daniel at wagner-home.com>
 * depend on data-default, and deprecate the monomorphic name defaultConfig


--
This message was brought to you by DarcsWatch
http://darcswatch.nomeata.de/repo_http:__code.haskell.org_xmonad.html#bundle-0d919c9a83ab190d6dcb47cc3419ddace3a052b3


Reply | Threaded
Open this post in threaded view
|

patches to use data-default

Carlos López Camey
In reply to this post by wagnerdm@seas.upenn.edu
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/xmonad/attachments/20130529/12d5f453/attachment.htm>

Reply | Threaded
Open this post in threaded view
|

patches to use data-default

Adam Vogt
On Wed, May 29, 2013 at 6:45 AM, Carlos L?pez Camey <c.lopez at kmels.net> wrote:
> 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


Reply | Threaded
Open this post in threaded view
|

patches to use data-default

Jesper Reenberg
In reply to this post by wagnerdm@seas.upenn.edu
On 28 May 2013 03:47, Daniel Wagner <wagnerdm at seas.upenn.edu> 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?
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/xmonad/attachments/20130628/f2f0a2e8/attachment.htm>

Reply | Threaded
Open this post in threaded view
|

patches to use data-default

Daniel Wagner
On 2013-06-27 19:08, Jesper Reenberg wrote:

> On 28 May 2013 03:47, Daniel Wagner <wagnerdm at seas.upenn.edu> 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


Reply | Threaded
Open this post in threaded view
|

patches to use data-default

Carlos López Camey
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 <daniel at wagner-home.com>

> On 2013-06-27 19:08, Jesper Reenberg wrote:
>
>> On 28 May 2013 03:47, Daniel Wagner <wagnerdm at seas.upenn.edu> 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 at haskell.org
> http://www.haskell.org/**mailman/listinfo/xmonad<http://www.haskell.org/mailman/listinfo/xmonad>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/xmonad/attachments/20130720/9a4bb9af/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: data-default-dependency-fix.dpatch
Type: application/octet-stream
Size: 24518 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/xmonad/attachments/20130720/9a4bb9af/attachment.obj>

Reply | Threaded
Open this post in threaded view
|

patches to use data-default

Daniel Wagner
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 <daniel at wagner-home.com>
>
>> On 2013-06-27 19:08, Jesper Reenberg wrote:
>> On 28 May 2013 03:47, Daniel Wagner <wagnerdm at seas.upenn.edu>
>> 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 at haskell.org
>  http://www.haskell.org/mailman/listinfo/xmonad [1]
>
>
>
> Links:
> ------
> [1] http://www.haskell.org/mailman/listinfo/xmonad
>
> _______________________________________________
> xmonad mailing list
> xmonad at haskell.org
> http://www.haskell.org/mailman/listinfo/xmonad



Reply | Threaded
Open this post in threaded view
|

patches to use data-default

Adam Vogt
On Sat, Jul 20, 2013 at 6:58 PM, Daniel Wagner <daniel at wagner-home.com> wrote:
> 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