Trex illegal? overlapping instances for derived classes -- is this intended?
Anthony Clayden <[email protected]> Fri, 27 Jun 2025 14:47:57 +1200
| Newsgroups | gmane.comp.lang.haskell.hugs.bugs |
|---|---|
| Message-ID | <CABU_mxjpBYVkUarR1cxUYLwXZaYcef1ecs34yKZP7dZw=eegaw@mail.gmail.com> |
--===============5574529289004812844==
Content-Type: multipart/alternative; boundary="00000000000036595c063884b556"
--00000000000036595c063884b556
Content-Type: text/plain; charset="UTF-8"
>
> ... 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.)
--00000000000036595c063884b556
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">><br><div>> ...=C2=A0<span style=3D"color:rgb(0,0,0)=
;white-space:pre-wrap">decls that aren't allowed if I try to put </span=
><span style=3D"color:rgb(0,0,0);white-space:pre-wrap">them explicitly.</sp=
an></div><div><span style=3D"color:rgb(0,0,0);white-space:pre-wrap">> Th=
ey're rejected as overlapping, and in no </span><span style=3D"color:rg=
b(0,0,0);white-space:pre-wrap">substitution ordering.</span></div><div><spa=
n style=3D"color:rgb(0,0,0);white-space:pre-wrap">></span></div><div><sp=
an style=3D"color:rgb(0,0,0);white-space:pre-wrap"><br></span></div><div><s=
pan style=3D"color:rgb(0,0,0);white-space:pre-wrap">Ah, I see this limitati=
on is acknowledged in SPJ&MPJ 1999 '</span>Lightweight Extensible R=
ecords for Haskell' proposal.</div><div><a href=3D"https://www.microsof=
t.com/en-us/research/wp-content/uploads/1999/01/recpro.pdf">https://www.mic=
rosoft.com/en-us/research/wp-content/uploads/1999/01/recpro.pdf</a><span st=
yle=3D"color:rgb(0,0,0);white-space:pre-wrap"><br></span></div><div><span s=
tyle=3D"color:rgb(0,0,0);white-space:pre-wrap"><br></span></div><div><span =
style=3D"color:rgb(0,0,0);white-space:pre-wrap">Section 5.3 Instances:</spa=
n></div><div><span style=3D"color:rgb(0,0,0);white-space:pre-wrap"><br></sp=
an></div><div><span style=3D"color:rgb(0,0,0);white-space:pre-wrap">> </=
span>instance D {r|x::a} where ... -- INSTANCES</div>> instance D {r|y::=
b} where ... -- OVERLAP!<div><br></div><div>(Note under that proposal the `=
r` representing the 'tail' of the record is prefixed.)</div><div><b=
r></div><div>For the record, I amended Hugs/Trex such that those instances =
do not overlap, provided each instance head mentions only a single label, a=
nd the labels are distinct. (Or depending on your point of view: they do ov=
erlap, but in a strictly-more-specific ordering given by the canonical orde=
ring of labels.)</div><div><br></div><div><br></div></div>
--00000000000036595c063884b556--
--===============5574529289004812844==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Disposition: inline
X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KSHVncy1CdWdz
IG1haWxpbmcgbGlzdApIdWdzLUJ1Z3NAaGFza2VsbC5vcmcKaHR0cDovL21haWwuaGFza2VsbC5v
cmcvY2dpLWJpbi9tYWlsbWFuL2xpc3RpbmZvL2h1Z3MtYnVncw==
--===============5574529289004812844==--