Re: Merging the OpenGLRaw and gl packages
Oliver Charles <[email protected]> Thu, 01 Oct 2015 09:01:10 +0000
| Newsgroups | gmane.comp.lang.haskell.cafe,gmane.comp.lang.haskell.hopengl |
|---|---|
| Message-ID | <CAGRp5RmoNM7NR8sGoRBtpWJNdb1c8m0TfixkvyVA-sYPo4x8Lw@mail.gmail.com> |
--===============7548120173204886096== Content-Type: multipart/alternative; boundary=001a11410fba611e5f0521074a03 --001a11410fba611e5f0521074a03 Content-Type: text/plain; charset=UTF-8 On Wed, Sep 30, 2015 at 6:38 PM Sven Panne <[email protected]> wrote: > IMHO using pattern synonyms vs. plain old Haskell values is to a large > part just bikeshedding, at least in the trivial case at hand where we talk > about simple integral values. It basically boils down to the question: Is > > foo x = case x of > GL_BAR -> expr1 > GL_BAZ -> expr2 > _ -> expr3 > > really so much better than > > foo x > | x == GL_BAR = expr1 > | x == GL_BAZ = expr2 > | otherwise = expr3 > Yes, because the first approach is an expression that you can use anywhere. Sure, there's little difference when you do it at the "top" of a function definition, as you're doing. 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 == ... -> ...) --001a11410fba611e5f0521074a03 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr"><div class=3D"gmail_quote"><div dir=3D"ltr">On Wed, Sep 30= , 2015 at 6:38 PM Sven Panne <<a href=3D"mailto:[email protected]">sve= [email protected]</a>> wrote:<br></div><blockquote class=3D"gmail_quote" = style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><di= v dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">IMHO us= ing pattern synonyms vs. plain old Haskell values is to a large part just b= ikeshedding, at least in the trivial case at hand where we talk about simpl= e integral values. It basically boils down to the question: Is<br></div></d= iv></div><div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_qu= ote"><div><br></div><div>=C2=A0 =C2=A0foo x =3D case x of</div><div>=C2=A0 = =C2=A0 =C2=A0GL_BAR -> expr1</div><div>=C2=A0 =C2=A0 =C2=A0GL_BAZ -> = expr2</div><div>=C2=A0 =C2=A0 =C2=A0_ -> expr3</div><div><br></div><div>= really so much better than</div><div><br></div><div>=C2=A0 =C2=A0foo x</div= ><div>=C2=A0 =C2=A0 =C2=A0| x =3D=3D GL_BAR =3D expr1</div><div><div>=C2=A0= =C2=A0 =C2=A0| x =3D=3D GL_BAZ =3D expr2</div></div><div>=C2=A0 =C2=A0 =C2= =A0| otherwise =3D expr3</div></div></div></div></blockquote><div><br></div= ><div>Yes, because the first approach is an expression that you can use any= where. Sure, there's little difference when you do it at the "top&= quot; of a function definition, as you're doing. However, it's a lo= t more significant if you want to do something like:</div><div><br></div><d= iv>foo x =3D doSomething (case x of ...)</div><div><br></div><div>Without p= attern synonyms, you either have</div><div><br></div><div>foo x =3D doSomet= hing x'</div><div>=C2=A0 where x' | x =3D=3D ... =3D ...</div><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 ... -> ...)</d= iv></div></div> --001a11410fba611e5f0521074a03-- --===============7548120173204886096== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Haskell-Cafe mailing list [email protected] http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe --===============7548120173204886096==--