Closed dbaynard closed 5 years ago
Actually, I could combine them all into a single, Default
newtype.
Sounds like a good idea to me! I'd happily accept a pull request implementing this idea.
You might also consider having another newtype for GFunctor
, GFoldable
, GTraversable
, and GCopoint
, since those classes have different kinds than the others.
I've done the Default
instances at https://github.com/dbaynard/generic-deriving/tree/feat/deriving-via.
Instances for the higher kinded classes are in progress.
Current state
Default
or Default1
for all the classes. I had to export an internal type from the Uniplate
module to do so.Uniplate
and some Semigroup
/Monoid
issues I haven't yet investigated. I think the fix for the roles issue involves QuantifiedConstraints
(good job it is in 8.6 too).Sounds promising! Can you submit a pull request?
In response to your points:
hspec
, so we can at least test some things.)I'll PR now.
I meant, it implements, say, Functor
, but using neither GFunctor
nor GFunctor'
, for use with DerivingVia
. These Default
data types could actually then be implemented in a separate package, which would not depend on this package. If the performance is the same, this PR wouldn't be as desirable.
I meant, it implements, say,
Functor
, but using neitherGFunctor
norGFunctor'
, for use withDerivingVia
. TheseDefault
data types could actually then be implemented in a separate package, which would not depend on this package. If the performance is the same, this PR wouldn't be as desirable.
Ah, I see what you mean. Yes, personally speaking, I would prefer that we only handle the G
classes. The way I see it, the classes in this library are mostly provided for pedagogical purposes so as to provide simple examples of datatype-generic programming. If one wanted to derive, say, Functor
, I would encourage them to use the generic-data
library instead, which doesn't have the same dependency footprint/backwards compatibility constraints as this library.
Following MuniHac I've been learning to use
DerivingVia
. As some of my newtypes just use the default implementations, it might make sense to export them from this library (at no maintainance cost for pre-8.6 GHC).Edit: Actually, it makes sense to have a single
newtype Default a = Default a
for any implementation which just uses the defaults.I've only just started with this, but I believe most, if not all, classes in this library would benefit from this. Happy to PR.
For example, for
Eq
:And for
Enum
:Then I can simply add the following, to use the default implementations without needing to explicitly write out the
where geq = geqdefault
line.My example is in https://github.com/dbaynard/generic-programming-munihac-2018/tree/record — I'm investigating how much ancilliary information I can ergonomically fit into type definitions.