NamedFieldPuns in HugsMode
Anthony Clayden <[email protected]> Tue, 17 May 2022 21:10:51 +1200
| Newsgroups | gmane.comp.lang.haskell.hugs.user |
|---|---|
| Message-ID | <CABU_mxh+6Pk7DGJ9BtemQPMJv13zvB0Onq0Hq6i5Fb_xK+B4Ew@mail.gmail.com> |
--===============5724107024506603879==
Content-Type: multipart/alternative; boundary="000000000000c4c7cc05df318447"
--000000000000c4c7cc05df318447
Content-Type: text/plain; charset="UTF-8"
There's an (AFAICT) undocumented feature in Hugs, which behaves the same as
GHC -XNamedFieldPuns
> data Thing a = MkThing {field :: a}
> foo MkThing{ field } = field
> -- ^^^^ shorthand for { field = field }
AntC
--000000000000c4c7cc05df318447
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">There's an (AFAICT) undocumented feature in Hugs, whic=
h behaves the same as GHC -XNamedFieldPuns=C2=A0<div><font face=3D"monospac=
e"><br></font></div><div><font face=3D"monospace">><span class=3D"gmail-=
pl-k" style=3D"color:rgb(36,41,47);box-sizing:border-box">
=C2=A0=C2=A0=C2=A0data</span><span style=3D"color:rgb(36,41,47)"> </span><s=
pan class=3D"gmail-pl-en" style=3D"color:rgb(36,41,47);box-sizing:border-bo=
x">Thing</span><span style=3D"color:rgb(36,41,47)"> </span><span class=3D"g=
mail-pl-smi" style=3D"color:rgb(36,41,47);box-sizing:border-box">a</span><s=
pan style=3D"color:rgb(36,41,47)"> </span><span class=3D"gmail-pl-k" style=
=3D"color:rgb(36,41,47);box-sizing:border-box">=3D</span><span style=3D"col=
or:rgb(36,41,47)"> </span><span class=3D"gmail-pl-ent" style=3D"color:rgb(3=
6,41,47);box-sizing:border-box">MkThing</span><span style=3D"color:rgb(36,4=
1,47)"> </span><span class=3D"gmail-pl-k" style=3D"color:rgb(36,41,47);box-=
sizing:border-box">{</span><span class=3D"gmail-pl-e" style=3D"color:rgb(36=
,41,47);box-sizing:border-box">field</span><span style=3D"color:rgb(36,41,4=
7)"> </span><span class=3D"gmail-pl-k" style=3D"color:rgb(36,41,47);box-siz=
ing:border-box">::</span><span style=3D"color:rgb(36,41,47)"> </span><span =
class=3D"gmail-pl-smi" style=3D"color:rgb(36,41,47);box-sizing:border-box">=
a</span><span class=3D"gmail-pl-k" style=3D"color:rgb(36,41,47);box-sizing:=
border-box">}</span></font></div><div><span class=3D"gmail-pl-k" style=3D"c=
olor:rgb(36,41,47);box-sizing:border-box"><font face=3D"monospace">>=C2=
=A0 =C2=A0 foo MkThing{ field } =3D field</font></span></div><div><span cla=
ss=3D"gmail-pl-k" style=3D"color:rgb(36,41,47);box-sizing:border-box"><font=
face=3D"monospace">>=C2=A0 =C2=A0 --=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0^^^^ shorthand for { field =3D field }</font></span></div><div><span =
class=3D"gmail-pl-k" style=3D"color:rgb(36,41,47);box-sizing:border-box"><f=
ont face=3D"monospace"><br></font></span></div><div><span class=3D"gmail-pl=
-k" style=3D"color:rgb(36,41,47);box-sizing:border-box"><font face=3D"monos=
pace"><br></font></span></div><div><span class=3D"gmail-pl-k" style=3D"colo=
r:rgb(36,41,47);box-sizing:border-box"><font face=3D"monospace">AntC</font>=
</span></div><pre style=3D"box-sizing:border-box;font-family:ui-monospace,S=
FMono-Regular,"SF Mono",Menlo,Consolas,"Liberation Mono"=
;,monospace;font-size:13.6px;margin-top:0px;margin-bottom:0px;padding:16px;=
overflow:auto;line-height:1.45;border-radius:6px;word-break:normal;color:rg=
b(36,41,47)"><br></pre><pre style=3D"box-sizing:border-box;font-family:ui-m=
onospace,SFMono-Regular,"SF Mono",Menlo,Consolas,"Liberation=
Mono",monospace;font-size:13.6px;margin-top:0px;margin-bottom:0px;pad=
ding:16px;overflow:auto;line-height:1.45;border-radius:6px;word-break:norma=
l;color:rgb(36,41,47)"><br></pre></div>
--000000000000c4c7cc05df318447--
--===============5724107024506603879==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Disposition: inline
X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KSHVncy1Vc2Vy
cyBtYWlsaW5nIGxpc3QKSHVncy1Vc2Vyc0BoYXNrZWxsLm9yZwpodHRwOi8vbWFpbC5oYXNrZWxs
Lm9yZy9jZ2ktYmluL21haWxtYW4vbGlzdGluZm8vaHVncy11c2Vycwo=
--===============5724107024506603879==--