Re: FunDeps: divergent improvement from overlapping instances

Anthony Clayden <[email protected]> Mon, 22 Aug 2022 13:54:54 +1200
Newsgroups gmane.comp.lang.haskell.hugs.user
Message-ID <CABU_mxjv5rY19mPjHPERqEfXS5qLU05bjoSS3gt3fBwa5f-X8w@mail.gmail.com>
--===============7447684573904059856==
Content-Type: multipart/alternative; boundary="000000000000805d5f05e6cabcd9"

--000000000000805d5f05e6cabcd9
Content-Type: text/plain; charset="UTF-8"

> I'm now working on the instance sequencing routines, to ignore those
> divergent Dependent positions when deciding overlap ordering.

Ok. Done. So this works:

>* class     TypeEq a b e  | a b -> e
*>* instance TypeEq a a TTrue
*>* instance TypeEq a b TFalse*


In case of multiple FunDeps for an instance, improvement must use all
FunDeps for a given instance, but not go on to improve from a less
specific instance -- if one of the FunDeps is Full.


Note a Full FunDep needn't actually deliver any improvement (change of
types) for this 'don't go on' to apply -- it's sufficient if some
other improvement has already got the Wanted to match the instance.
(In effect this is selecting the instance -- although Hugs doesn't
'officially' do so until a later step.)


Getting the preference sequence of instances was tricky -- especially
in case of multiple FunDeps: in comparing two instance heads, they
might be apart going by some FunDeps, but overlapping going by others.

--000000000000805d5f05e6cabcd9
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><font face=3D"arial, sans-serif">&gt;=C2=A0<span style=3D"=
color:rgb(0,0,0);white-space:pre-wrap">I&#39;m now working on the instance =
sequencing routines, to ignore those</span></font><div><span style=3D"color=
:rgb(0,0,0);white-space:pre-wrap"><font face=3D"arial, sans-serif">&gt; div=
ergent Dependent positions when deciding overlap ordering.</font></span></d=
iv><div><span style=3D"color:rgb(0,0,0);white-space:pre-wrap"><font face=3D=
"arial, sans-serif"><br></font></span></div><div><span style=3D"color:rgb(0=
,0,0);white-space:pre-wrap"><font face=3D"arial, sans-serif">Ok. Done. So t=
his works:</font></span></div><div><span style=3D"color:rgb(0,0,0);white-sp=
ace:pre-wrap"><font face=3D"arial, sans-serif"><br></font></span></div><div=
><pre style=3D"white-space:pre-wrap;color:rgb(0,0,0)"><font face=3D"arial, =
sans-serif">&gt;<i> class     TypeEq a b e  | a b -&gt; e
</i>&gt;<i> instance TypeEq a a TTrue
</i>&gt;<i> instance TypeEq a b TFalse</i></font></pre><pre style=3D"white-=
space:pre-wrap;color:rgb(0,0,0)"><font face=3D"arial, sans-serif"><br></fon=
t></pre><pre style=3D"white-space:pre-wrap;color:rgb(0,0,0)"><font face=3D"=
arial, sans-serif">In case of multiple FunDeps for an instance, improvement=
 must use all FunDeps for a given instance, but not go on to improve from a=
 less specific instance -- if one of the FunDeps is Full.</font></pre><pre =
style=3D"white-space:pre-wrap;color:rgb(0,0,0)"><font face=3D"arial, sans-s=
erif"><br></font></pre><pre style=3D"white-space:pre-wrap;color:rgb(0,0,0)"=
><font face=3D"arial, sans-serif">Note a Full FunDep needn&#39;t actually d=
eliver any improvement (change of types) for this &#39;don&#39;t go on&#39;=
 to apply -- it&#39;s sufficient if some other improvement has already got =
the Wanted to match the instance. (In effect this is selecting the instance=
 -- although Hugs doesn&#39;t &#39;officially&#39; do so until a later step=
.)</font></pre><pre style=3D"white-space:pre-wrap;color:rgb(0,0,0)"><font f=
ace=3D"arial, sans-serif"><br></font></pre><pre style=3D"white-space:pre-wr=
ap;color:rgb(0,0,0)"><font face=3D"arial, sans-serif">Getting the preferenc=
e sequence of instances was tricky -- especially in case of multiple FunDep=
s: in comparing two instance heads, they might be apart going by some FunDe=
ps, but overlapping going by others.</font></pre></div></div>

--000000000000805d5f05e6cabcd9--

--===============7447684573904059856==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Disposition: inline

X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KSHVncy1Vc2Vy
cyBtYWlsaW5nIGxpc3QKSHVncy1Vc2Vyc0BoYXNrZWxsLm9yZwpodHRwOi8vbWFpbC5oYXNrZWxs
Lm9yZy9jZ2ktYmluL21haWxtYW4vbGlzdGluZm8vaHVncy11c2Vycwo=

--===============7447684573904059856==--