<div dir="auto"><div>Ryan Scott has argued that abstract types should not have Generic instances at all. I'll let him make those arguments himself, but I think I should mention that it's really hard to write instances that set up all the appropriate type-level meta-data. Some of it (like the extra-full package name) may only be doable with Template Haskell. Furthermore, some of the metadata types change from GHC version to version.</div><div dir="auto"><br></div><div dir="auto">As for laws, I think you *probably* meant</div><div dir="auto"><br></div><div dir="auto">to . from = id</div><div dir="auto"><br></div><div dir="auto">That is, that you can convert a value to its generic representation and back and get the "same" value back.</div><div dir="auto"><br></div><div dir="auto">I think that's likely sufficient for most purposes, but probably not all. At the very least, it's something people using your instance would need to be aware of. If either function is partial, you will be in a world of pain if you try to use something like generic serialization.</div><div dir="auto"><div class="gmail_extra" dir="auto"><br><div class="gmail_quote">On Mar 20, 2017 4:53 PM, "Gershom B" <<a href="mailto:gershomb@gmail.com">gershomb@gmail.com</a>> wrote:<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I had a bit of discussion today on how to handle generic instances for<br>
abstract types.<br>
<br>
It resolved to the following question, in a sense -- what are the laws<br>
for the Generic typeclass?<br>
<br>
Should require that `from` and `to` be an isomorphism of data types<br>
(i.e. that `from . to` and `to . from` both be the identity) or should<br>
we require only the weaker one-sided retract condition (i.e. that<br>
`from . to` be the identity.). If the latter, is it better that `from`<br>
be partial (which i  prefer) or that it quotient together "equivalent"<br>
representations (i.e. representing a map as a `fromList` as<br>
syb-generics do).<br>
<br>
The documentation doesn't seem to provide clear guidance here, and it<br>
might be worth discussing if some should be added.<br>
<br>
Cheers,<br>
Gershom<br>
______________________________<wbr>_________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org">Libraries@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-<wbr>bin/mailman/listinfo/libraries</a><br>
</blockquote></div><br></div></div></div>