Laws for GHC.Generics

Gershom B gershomb at gmail.com
Mon Mar 20 20:52:52 UTC 2017


I had a bit of discussion today on how to handle generic instances for
abstract types.

It resolved to the following question, in a sense -- what are the laws
for the Generic typeclass?

Should require that `from` and `to` be an isomorphism of data types
(i.e. that `from . to` and `to . from` both be the identity) or should
we require only the weaker one-sided retract condition (i.e. that
`from . to` be the identity.). If the latter, is it better that `from`
be partial (which i  prefer) or that it quotient together "equivalent"
representations (i.e. representing a map as a `fromList` as
syb-generics do).

The documentation doesn't seem to provide clear guidance here, and it
might be worth discussing if some should be added.

Cheers,
Gershom


More information about the Libraries mailing list