This is the second part in my series of practical applications of the
QuantifiedConstraints extension. See
for part 1.
Generic1 classes are extremely useful tools in a GHC
programmer’s toolbox, but their utility is currently limited in the sense that
one can only derive
Generic instances for simple data types. By “simple”, I
mean that GHC will simply error if you try to derive
Generic a more
sophisticated data type—a GADT—like this one:
We’re drawing closer to a release of GHC 8.2, which will feature a variety of enhancements to GHC’s
deriving-related extensions. None of the improvements are particularly revolutionary, and for most code, you won’t notice a difference. But there are quite a few quality-of-life fixes that should make doing certain things with
deriving a little less of a hassle.
GHC 8.0 will be released soon, and with it comes many new additions and improvements to the
base library. In particular, the API in the
GHC.Generics module (and the underlying machinery provided by the
DeriveGeneric GHC extension) have undergone quite a few improvements. However, these changes haven’t been very well advertised outside of the GHC dev community, so hopefully this blog post will spread awareness of some of the new bells and whistles in GHC generics.