PROPOSAL: Add instances to Data.Monoid newtype wrappers

As of base 4.7.0.1, none of the newtype wrappers in Data.Monoid have instances for: - Typeable - Data - Functor It looks like the base library repository has AutoDeriveTypeable, so I presume that takes care of the Typeable instances. It also looks like First and Last now have Functor instances, amongst others. In particular, I would like to add Functor instances for all parameterized types, where applicable (i.e. Dual, Sum, Product). In general, I think we should add whatever other instances make sense. Data came to mind. Others? Discussion period: 2 weeks (or perhaps until after the beginning of the new year) Regards, Sean

+1 Seems obvious. People shouldn't have to define orphan instances for
these. Any instance (of a class in base) that makes sense should be
included whenever possible.
-- Dan Burton
On Thu, Dec 11, 2014 at 7:30 AM, Sean Leather
As of base 4.7.0.1, none of the newtype wrappers in Data.Monoid have instances for:
- Typeable - Data - Functor
It looks like the base library repository has AutoDeriveTypeable, so I presume that takes care of the Typeable instances. It also looks like First and Last now have Functor instances, amongst others.
In particular, I would like to add Functor instances for all parameterized types, where applicable (i.e. Dual, Sum, Product).
In general, I think we should add whatever other instances make sense. Data came to mind. Others?
Discussion period: 2 weeks (or perhaps until after the beginning of the new year)
Regards, Sean
_______________________________________________ Libraries mailing list Libraries@haskell.org http://www.haskell.org/mailman/listinfo/libraries

Sean Leather
As of base 4.7.0.1, none of the newtype wrappers in Data.Monoid have instances for:
- Typeable - Data - Functor
It looks like the base library repository has AutoDeriveTypeable, so I presume that takes care of the Typeable instances. It also looks like First and Last now have Functor instances, amongst others.
In particular, I would like to add Functor instances for all parameterized types, where applicable (i.e. Dual, Sum, Product).
In general, I think we should add whatever other instances make sense. Data came to mind. Others?
+1, I believe the general feeling is: add canonical type class instances whether one exists. These instances certainly make sense. -- ocharles

Sean Leather wrote:
newtype wrappers in Data.Monoid... I would like to add Functor instances for all parameterized types, where applicable (i.e. Dual, Sum, Product). In general, I think we should add whatever other instances make sense. Data came to mind.
+1
Others?
NFData. But that's not in base, so those instances need to be added in the deepseq library. -Yitz

On Thu, Dec 11, 2014 at 6:50 PM, Yitzchak Gale wrote:
Others?
NFData. But that's not in base, so those instances need to be added in the deepseq library.
Looks like the instances are already there: https://github.com/haskell/deepseq/blob/master/Control/DeepSeq.hs#L329-L352 Regards, Sean

I'm a very strong +1 on this.
We've already sat down to add some of these, and there was a general
resolution by the core libraries committee in response to a similar raised
issue for the types in GHC.Generics that missing instances like this that
have obvious canonical implementations should be added wherever possible.
-Edward
On Fri, Dec 12, 2014 at 2:30 AM, Sean Leather
As of base 4.7.0.1, none of the newtype wrappers in Data.Monoid have instances for:
- Typeable - Data - Functor
It looks like the base library repository has AutoDeriveTypeable, so I presume that takes care of the Typeable instances. It also looks like First and Last now have Functor instances, amongst others.
In particular, I would like to add Functor instances for all parameterized types, where applicable (i.e. Dual, Sum, Product).
In general, I think we should add whatever other instances make sense. Data came to mind. Others?
Discussion period: 2 weeks (or perhaps until after the beginning of the new year)
Regards, Sean
_______________________________________________ Libraries mailing list Libraries@haskell.org http://www.haskell.org/mailman/listinfo/libraries

Since many of these are just the identity functor, should we just add
all class instances? So in addition to Functor, also add Foldable and
Traversable, and perhaps even Applicative, Monad, Alternative,
MonadPlus, MonadFix?
I'm +1 on the obviously useful instances (Data, Functor) and wouldn't
mind the others either, since I don't see any downsides.
Erik
On Thu, Dec 11, 2014 at 9:20 PM, Edward Kmett
I'm a very strong +1 on this.
We've already sat down to add some of these, and there was a general resolution by the core libraries committee in response to a similar raised issue for the types in GHC.Generics that missing instances like this that have obvious canonical implementations should be added wherever possible.
-Edward
On Fri, Dec 12, 2014 at 2:30 AM, Sean Leather
wrote: As of base 4.7.0.1, none of the newtype wrappers in Data.Monoid have instances for:
Typeable Data Functor
It looks like the base library repository has AutoDeriveTypeable, so I presume that takes care of the Typeable instances. It also looks like First and Last now have Functor instances, amongst others.
In particular, I would like to add Functor instances for all parameterized types, where applicable (i.e. Dual, Sum, Product).
In general, I think we should add whatever other instances make sense. Data came to mind. Others?
Discussion period: 2 weeks (or perhaps until after the beginning of the new year)
Regards, Sean
_______________________________________________ Libraries mailing list Libraries@haskell.org http://www.haskell.org/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://www.haskell.org/mailman/listinfo/libraries

Hello Sean, On 2014-12-11 at 16:30:53 +0100, Sean Leather wrote:
As of base 4.7.0.1, none of the newtype wrappers in Data.Monoid have instances for:
- Typeable - Data - Functor
It looks like the base library repository has AutoDeriveTypeable, so I presume that takes care of the Typeable instances.
As a side-note: base-4.7 had AutoDeriveTypeable enabled as well for that module, however, AutoDeriveTypeable is broken in GHC 7.8 (fails to derive instances in most cases), only starting with GHC 7.10 it is working properly.
It also looks like First and Last now have Functor instances, amongst others.
Jfyi, here's a current documentation snapshot for the upcoming base-4.8: https://hackage.haskell.org/package/base-4.8.0.0/candidate/docs/Data-Monoid....
In particular, I would like to add Functor instances for all parameterized types, where applicable (i.e. Dual, Sum, Product).
In general, I think we should add whatever other instances make sense. Data came to mind. Others?
Do you mind making a concrete list of which instances missing for each newtype wrapper asap? That way we can already add them (assuming they are all nobrainers) optimistically before GHC 7.10.1RC1 ships (and should anything turn out to be problematic (which doesn't seem likely given the current discussion progress) we can kill them again by RC2) Cheers, hvr

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 +1. - -- Alexander alexander@plaimi.net https://secure.plaimi.net/~alexander -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iF4EAREIAAYFAlSMQCAACgkQRtClrXBQc7VjJwD/Y2G89u3Q6mnMlORuuwZa+T8m oAhVqeO3Ad0eDGjuejgA/1/AxlBBVBLG+2qJe0ZfkZjJzpm5wBQxb8TSImuEDTER =Keio -----END PGP SIGNATURE-----
participants (8)
-
Alexander Berntsen
-
Dan Burton
-
Edward Kmett
-
Erik Hesselink
-
Herbert Valerio Riedel
-
Oliver Charles
-
Sean Leather
-
Yitzchak Gale