Re: [Haskell-cafe] Merging the OpenGLRaw and gl packages
Sven Panne <[email protected]> Thu, 1 Oct 2015 18:54:42 +0200
| Newsgroups | gmane.comp.lang.haskell.hopengl,gmane.comp.lang.haskell.cafe |
|---|---|
| Message-ID | <CANBN=mtnUgU-Kdec54mC02=UBBsgh_si+3mSMUVfZpGhGy70kA@mail.gmail.com> |
--===============2823609285841104089== Content-Type: multipart/alternative; boundary=001a1144170e5485ee05210de76a --001a1144170e5485ee05210de76a Content-Type: text/plain; charset=UTF-8 2015-10-01 11:01 GMT+02:00 Oliver Charles <[email protected]>: > [...] However, it's a lot more significant if you want to do something > like: > > foo x = doSomething (case x of ...) > > Without pattern synonyms, you either have > > foo x = doSomething x' > where x' | x == ... = ... > > or > > {-# LANGUAGE MultiWayIf #-} > > foo x = doSomething (if | x == ... -> ...) > Or simply in plain old Haskell (basically the desugaring of the multi-way-if): foo x = doSomething (case () of _ | x == gl_BAR -> expr1 | x == gl_BAZ -> expr2 | otherwise -> expr3) Compared to: foo x = doSomething (case x of GL_BAR -> expr1 GL_BAZ -> expr2 _ .> expr3) it doesn't really look *that* much different IMHO, given the high price one has to pay for a tiny improvement in readability. But that's my personal, more conservative view of things, and I'm here to see what other people prefer.Alas, up to now, this is not very conclusive... :-/ --001a1144170e5485ee05210de76a Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">2015= -10-01 11:01 GMT+02:00 Oliver Charles <span dir=3D"ltr"><<a href=3D"mail= to:[email protected]" target=3D"_blank">[email protected]</a>></= span>:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;bord= er-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div class=3D"gma= il_quote"><span class=3D""><div dir=3D"ltr">[...] However, it's a lot m= ore significant if you want to do something like:<br></div></span><div><br>= </div><div>foo x =3D doSomething (case x of ...)</div><div><br></div><div>W= ithout pattern synonyms, you either have</div><div><br></div><div>foo x =3D= doSomething x'</div><div>=C2=A0 where x' | x =3D=3D ... =3D ...</d= iv><div><br></div><div>or</div><div><br></div><div>{-# LANGUAGE MultiWayIf = #-}</div><div><br></div><div>foo x =3D doSomething (if | x =3D=3D ... ->= ...)</div></div></div> </blockquote></div><br></div><div class=3D"gmail_extra">Or simply in plain = old Haskell (basically the desugaring of the multi-way-if):</div><div class= =3D"gmail_extra"><br></div><div class=3D"gmail_extra">=C2=A0 =C2=A0foo x = =3D doSomething (case () of</div><div class=3D"gmail_extra">=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0_ | x =3D=3D gl_BAR -> expr= 1</div><div class=3D"gmail_extra">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 | x =3D=3D gl_BAZ -> expr2</div><div class=3D"g= mail_extra">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 | otherwise -> expr3)</div><div class=3D"gmail_extra"><br></div><div= class=3D"gmail_extra">Compared to:</div><div class=3D"gmail_extra"><br></d= iv><div class=3D"gmail_extra">=C2=A0 =C2=A0foo x =3D doSomething (case x of= </div><div class=3D"gmail_extra">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 GL_BAR -> expr1</div><div class=3D"gmail_extra">=C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 GL_BAZ -> expr2</di= v><div class=3D"gmail_extra">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 _ .> expr3)</div><div class=3D"gmail_extra"><br></div><div= class=3D"gmail_extra">it doesn't really look *that* much different IMH= O, given the high price one has to pay for a tiny improvement in readabilit= y. But that's my personal, more conservative view of things, and I'= m here to see what other people prefer.Alas, up to now, this is not very co= nclusive... :-/</div></div> --001a1144170e5485ee05210de76a-- --===============2823609285841104089== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ HOpenGL mailing list [email protected] http://mail.haskell.org/cgi-bin/mailman/listinfo/hopengl --===============2823609285841104089==--