From anthony.d.clayden at gmail.com Fri Jun 27 02:47:57 2025 From: anthony.d.clayden at gmail.com (Anthony Clayden) Date: Fri, 27 Jun 2025 14:47:57 +1200 Subject: [hugs-bugs] Trex illegal? overlapping instances for derived classes -- is this intended? Message-ID: > > ... 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: