[Haskell-cafe] Merging the OpenGLRaw and gl packages
Oliver Charles
ollie at ocharles.org.uk
Thu Oct 1 09:01:10 UTC 2015
On Wed, Sep 30, 2015 at 6:38 PM Sven Panne <svenpanne at gmail.com> 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 == ... -> ...)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20151001/d689f647/attachment.html>
More information about the Haskell-Cafe
mailing list