Re: Datatype (and Newtype) contexts: improvement

Anthony Clayden <[email protected]> Thu, 15 Oct 2020 13:29:19 +1300
Newsgroups gmane.comp.lang.haskell.hugs.user
Message-ID <CABU_mxhPNsz9m2GU=UscDXEFSZorv0v2uoB9K0_OCneTweGE+Q@mail.gmail.com>
--===============3180515290049469674==
Content-Type: multipart/alternative; boundary="000000000000bac51d05b1aabd01"

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

Thanks Sam, apologies if I'm being dumb, but I'm not seeing the relevance
of 'boilerplate'.

I'm not trying to implement other compilers' language extensions (as would
be clear from my occasional posts on the Hugs list). If you want GHC
extensions, use GHC.

There's no hope of writing stock H98 or even H2010 code. The last Hugs
release (2006, used in HugsMode) has extensions way beyond the H2010
standard. I'm not trying to write code that's portable between GHC/Hugs.

I'm tinkering with Hugs to give it semantics that GHC doesn't support/not
even with all its extensions switched on. I'm tinkering in Hugs because it
seems to be achievable whereas I just have no idea how to build GHC; and I
suspect that even if I figured that out, tinkering inside GHC would be
orders of magnitude more complex, because I'd keep running into all sorts
of type-acrobat stuff from all of GHC's extensions.

And I say "more complex" even though GHC is written in Haskell, and Hugs is
written in C++ and I'd never programmed in C++ before working on Hugs; and
even though C++ is imperative code, not functional. Hugs mostly uses
vanilla C, with the ++ providing sourcecode edit directives -- so it goes
some way towards the macro-generator of 'boilerplate' anyway.

Realistically for 'industrial strength' applications like Cabal, GHC is the
only game in town. Cabal should be conservative and not try to use
'bleeding edge' GHC extensions, but things like MultiParam TypeClasses,
FlexibleInstances are very hard to do without (Hugs supports both). What's
more, I don't see how a macro-generator like 'boilerplate' is going to
help. It's not like you can macro-'translate' code using MPTCs back to H98.

AntC

On Thu, 15 Oct 2020 at 02:48, Sam Halliday <[email protected]> wrote:

>
> Sorry, I should have started a fresh email instead of responding to the
> mailing list.
>
> I just meant generally this might be of interest to you. The ability to
> generate the code that many language extensions are generating,
> therefore no need to add support in hugs. Making it easier for people to
> write portable stock Haskell98 code. Maybe even things like Cabal could
> be rewritten to use less extensions.
>
> Anthony Clayden wrote:
> > Hi Sam,
> >
> > I'm not seeing what relevance `boilerplate` has to anything I wrote.
> >
> > The compiler is generating the type for the constructors within a
> datatype
> > (whether or not the decl gives a context).
> >
> > On Wed, 14 Oct 2020 at 18:55, Sam Halliday <[email protected]>
> wrote:
> >
> >>
> >> Hi Anthony,
> >>
> >> Did you see this?
> >>
> >>   http://hackage.haskell.org/package/boilerplate
> >>
> >>
> >>
>
> --
> Best regards,
> Sam
>

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

<div dir=3D"ltr"><div dir=3D"ltr">Thanks Sam, apologies if I&#39;m being du=
mb, but I&#39;m not seeing the relevance of &#39;boilerplate&#39;.</div><di=
v><br></div><div>I&#39;m not trying to implement other compilers&#39; langu=
age extensions (as would be clear from my occasional posts on the Hugs list=
). If you want GHC extensions, use GHC.</div><div><br></div><div>There&#39;=
s no hope of writing stock H98 or even H2010 code. The last Hugs release (2=
006, used in HugsMode) has extensions way beyond the H2010 standard. I&#39;=
m not trying to write code that&#39;s portable between GHC/Hugs.</div><div>=
<br></div><div>I&#39;m tinkering with Hugs to give it semantics that GHC do=
esn&#39;t support/not even with all its extensions switched on. I&#39;m tin=
kering in Hugs because it seems to be achievable whereas I just have no ide=
a how to build GHC; and I suspect that even if I figured that out, tinkerin=
g inside GHC would be orders of magnitude more complex, because I&#39;d kee=
p running into all sorts of type-acrobat stuff from all of GHC&#39;s extens=
ions.</div><div><br></div><div>And I say &quot;more complex&quot; even thou=
gh GHC is written in Haskell, and Hugs is written in C++ and I&#39;d never =
programmed in C++ before working on Hugs; and even though C++ is imperative=
 code, not functional. Hugs mostly uses vanilla C, with the=C2=A0++ providi=
ng sourcecode edit directives -- so it goes some way towards the macro-gene=
rator of &#39;boilerplate&#39; anyway.</div><div><br></div><div>Realistical=
ly for &#39;industrial strength&#39; applications like Cabal, GHC is the on=
ly game in town. Cabal should be conservative and not try to use &#39;bleed=
ing edge&#39; GHC extensions, but things like MultiParam TypeClasses, Flexi=
bleInstances are very hard to do without (Hugs supports both). What&#39;s m=
ore, I don&#39;t see how a macro-generator like &#39;boilerplate&#39; is go=
ing to help. It&#39;s not like you can macro-&#39;translate&#39; code using=
 MPTCs back to H98.</div><div><br></div><div>AntC</div><br><div class=3D"gm=
ail_quote"><div dir=3D"ltr" class=3D"gmail_attr">On Thu, 15 Oct 2020 at 02:=
48, Sam Halliday &lt;<a href=3D"mailto:[email protected]">sam.halliday=
@gmail.com</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" style=
=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding=
-left:1ex"><br>
Sorry, I should have started a fresh email instead of responding to the<br>
mailing list.<br>
<br>
I just meant generally this might be of interest to you. The ability to<br>
generate the code that many language extensions are generating,<br>
therefore no need to add support in hugs. Making it easier for people to<br=
>
write portable stock Haskell98 code. Maybe even things like Cabal could<br>
be rewritten to use less extensions.<br>
<br>
Anthony Clayden wrote:<br>
&gt; Hi Sam,<br>
&gt;<br>
&gt; I&#39;m not seeing what relevance `boilerplate` has to anything I wrot=
e.<br>
&gt;<br>
&gt; The compiler is generating the type for the constructors within a data=
type<br>
&gt; (whether or not the decl gives a context).<br>
&gt;<br>
&gt; On Wed, 14 Oct 2020 at 18:55, Sam Halliday &lt;<a href=3D"mailto:sam.h=
[email protected]" target=3D"_blank">[email protected]</a>&gt; wrote:<=
br>
&gt;<br>
&gt;&gt;<br>
&gt;&gt; Hi Anthony,<br>
&gt;&gt;<br>
&gt;&gt; Did you see this?<br>
&gt;&gt;<br>
&gt;&gt;=C2=A0 =C2=A0<a href=3D"http://hackage.haskell.org/package/boilerpl=
ate" rel=3D"noreferrer" target=3D"_blank">http://hackage.haskell.org/packag=
e/boilerplate</a><br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
<br>
-- <br>
Best regards,<br>
Sam<br>
</blockquote></div></div>

--000000000000bac51d05b1aabd01--

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

X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KSHVncy1Vc2Vy
cyBtYWlsaW5nIGxpc3QKSHVncy1Vc2Vyc0BoYXNrZWxsLm9yZwpodHRwOi8vbWFpbC5oYXNrZWxs
Lm9yZy9jZ2ktYmluL21haWxtYW4vbGlzdGluZm8vaHVncy11c2Vycwo=

--===============3180515290049469674==--