Datatype Constructors: selector/matcher vs builder 'function'

Anthony Clayden <[email protected]> Tue, 5 Oct 2021 13:36:25 +1300
Newsgroups gmane.comp.lang.haskell.hugs.bugs
Message-ID <CABU_mxgq6Jtp1QZEMow8WMf3_nn26aFT19sC92AhyjkhTk4gMA@mail.gmail.com>
--===============1503197429261316346==
Content-Type: multipart/alternative; boundary="000000000000be45d805cd9038a5"

--000000000000be45d805cd9038a5
Content-Type: text/plain; charset="UTF-8"

From this discussion 'Contexts on datatype declarations'
http://web.archive.org/web/20151208175102/http://code.haskell.org/~dons/haskell-1990-2000/threads.html#04062

It looks like (at least at the time) GHC had separate functions for
matching vs building using a constructor.

In Hugs, the type for a datatype's constructor(s) is inferred in static.c
routine selectCtxt( ) called from depConstrs( ).

The type for field (label) selectors is inferred in type.c routine typeSel(
). And it's easy enough to hack that to drop the preds on the selectors, as
SPJ advocates in that thread.

What I can't find is where Hugs infers the type for a data constructor
appearing in matching position.

Any hints?  Thanks in advance

AntC

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

<div dir=3D"ltr"><div><font face=3D"arial, sans-serif"><br></font></div><fo=
nt face=3D"arial, sans-serif">From this discussion &#39;Contexts on datatyp=
e declarations&#39;</font><div><font face=3D"arial, sans-serif"><a href=3D"=
http://web.archive.org/web/20151208175102/http://code.haskell.org/~dons/has=
kell-1990-2000/threads.html#04062">http://web.archive.org/web/2015120817510=
2/http://code.haskell.org/~dons/haskell-1990-2000/threads.html#04062</a><br=
></font></div><div><font face=3D"arial, sans-serif"><br></font></div><div><=
font face=3D"arial, sans-serif">It looks like (at least at the time) GHC ha=
d separate functions for matching vs building using a constructor.</font></=
div><div><font face=3D"arial, sans-serif"><br></font></div><div><font face=
=3D"arial, sans-serif">In Hugs, the type for a datatype&#39;s constructor(s=
) is inferred in static.c routine selectCtxt( ) called from depConstrs( ).<=
/font></div><div><font face=3D"arial, sans-serif"><br></font></div><div><fo=
nt face=3D"arial, sans-serif">The type for field (label) selectors is infer=
red in type.c routine typeSel( ). And it&#39;s easy enough to hack that to =
drop the preds on the selectors, as SPJ advocates in that thread.</font></d=
iv><div><font face=3D"arial, sans-serif"><br></font></div><div><font face=
=3D"arial, sans-serif">What I can&#39;t find is where Hugs infers the type =
for a data constructor appearing in matching position.</font></div><div><fo=
nt face=3D"arial, sans-serif"><br></font></div><div><font face=3D"arial, sa=
ns-serif">Any hints?=C2=A0 Thanks in advance</font></div><div><font face=3D=
"arial, sans-serif"><br></font></div><div><font face=3D"arial, sans-serif">=
AntC</font></div><div><br></div></div>

--000000000000be45d805cd9038a5--

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

X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KSHVncy1CdWdz
IG1haWxpbmcgbGlzdApIdWdzLUJ1Z3NAaGFza2VsbC5vcmcKaHR0cDovL21haWwuaGFza2VsbC5v
cmcvY2dpLWJpbi9tYWlsbWFuL2xpc3RpbmZvL2h1Z3MtYnVncw==

--===============1503197429261316346==--