[Haskell-beginners] case statement
Brandon Allbery
allbery.b at gmail.com
Tue Jul 7 13:24:56 UTC 2015
On Tue, Jul 7, 2015 at 8:04 AM, Imants Cekusins <imantc at gmail.com> wrote:
> This "case" behaviour (patterns allow no access to outer scope
> variables) is different from some other languages.
>
In most functional languages, "case" is about structure, not values. You
specify the structure in terms of constructors, which must be literal.
Variables in patterns always capture values associated with those
constructors, never to values outside the case expression.
That said, doing a value-based comparison ("switch"-type construct) is
rather annoying, and most of Haskell's (and ghc extension) mechanisms only
reduce the pain somewhat. :/
--
brandon s allbery kf8nh sine nomine associates
allbery.b at gmail.com ballbery at sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20150707/ffe4893a/attachment.html>
More information about the Beginners
mailing list