mauke / data-default

A class for types with a default value
45 stars 16 forks source link

Add Generics support #9

Closed abbradar closed 8 years ago

abbradar commented 9 years ago

This adds support for Generics, allowing one to derive Default automagically if using recent enough GHC. This is primarily useful when declaring Default for big records (think database rows, these also often do already have a Generic instance to e.g. derive aesons classes), going especially nice with DeriveAnyClass in GHC 7.10. I've tried to make it is as semantically correct as possible (i.e. not defined it for sum types, as we can't know which one we should use). The support is made conditional using CPP, so users with other compilers than GHC (or old GHC versions) won't be affected. I've taken GHC 7.6.1 as a lower bound because then we skip depending on anything other than base. Overall this should be zero-impact for all users, while adding Generics support for those who need it.

abbradar commented 9 years ago

Any update on this? If this is unwanted, it would be nice to at least have a feedback telling so.