dreixel / generic-deriving

BSD 3-Clause "New" or "Revised" License
44 stars 32 forks source link

Consider removing all the redefined typeclasses #71

Closed fumieval closed 4 years ago

fumieval commented 4 years ago

This package has its own definitions of typeclasses (GShow, GMonoid, etc), but they are often not viable because they are incompatible with the existing instances. For example you can't derive GShow of a datatype if it contains a field that's an instance of Show but not GShow.

Same goes for everything else. Default method definitions are no longer a reason to redefine classes, now that we have DerivingVia.

RyanGlScott commented 4 years ago

The fact that GShow et al. aren't compatible with existing instances is by design, as these classes are primarily intended for educational purposes. That is, they exist to demonstrate how one can define GHC.Generics-based defaults for common type classes, without actually having to use the original type classes themselves. This has a number of advantages:

For these reasons, I usually recommend that people use generic-data rather than generic-deriving if they want GHC.Generics-based defaults for Semigroup, Show, etc. that use type classes from base.

Admittedly, the documentation for generic-deriving doesn't communicate this very well at the moment.

RyanGlScott commented 4 years ago

I've attempted to improve the documentation about this in #73.

fumieval commented 4 years ago

I see, thanks for explanation. I'm content as long as the purpose is documented