[hugs-bugs] Trex illegal? overlapping instances for derived classes -- is this intended?

Anthony Clayden anthony.d.clayden at gmail.com
Fri Jun 27 02:47:57 UTC 2025


>
> ... decls that aren't allowed if I try to put them explicitly.
> They're rejected as overlapping, and in no substitution ordering.
>

Ah, I see this limitation is acknowledged in SPJ&MPJ 1999 'Lightweight
Extensible Records for Haskell' proposal.
https://www.microsoft.com/en-us/research/wp-content/uploads/1999/01/recpro.pdf

Section 5.3 Instances:

> instance D {r|x::a} where ... -- INSTANCES
> instance D {r|y::b} where ... -- OVERLAP!

(Note under that proposal the `r` representing the 'tail' of the record is
prefixed.)

For the record, I amended Hugs/Trex such that those instances do not
overlap, provided each instance head mentions only a single label, and the
labels are distinct. (Or depending on your point of view: they do overlap,
but in a strictly-more-specific ordering given by the canonical ordering of
labels.)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/hugs-bugs/attachments/20250627/7cd06355/attachment.html>


More information about the Hugs-Bugs mailing list