[Haskell-cafe] lambda case

Jon Fairbairn jon.fairbairn at cl.cam.ac.uk
Fri Nov 30 11:24:48 CET 2012


Andreas Abel <andreas.abel at ifi.lmu.de> writes:

> I had been missing a pattern matching lambda in Haskell for
> a long time (SML had "fn" since ages) and my typical use
> will be
>
>   monadic_expr >>= \case
>     branches

We’ve been through that.  I want something similar, but would
have preferred something more algebraic.

> I think "\case" is not the worst choice, certainly better than
> "of" ...

What’s your argument? You’ll have to do better than blatant
assertion to convince me. Making “case exp” optional builds on
an existing expression syntax, giving an explicit meaning to a
part of it, so a reader only has to know that “of {alts}” is a
function and case does something specific with it. This “\case”
takes the keyword from that expression syntax and makes it a
special case of lambda, so a reader seeing a lambda now has to
check for a keyword instead of knowing straight off that the
next thing is going to be a variable.

Back when we originally designed Haskell there were lots of
things that people wanted to put in, and eventually we reached a
point where we said that we would only put something new in if
it allowed us to remove (or simplify) something else. “\case”
complicates lambda, using “of” simply breaks “case … of …” into
two easily understood parts.
-- 
Jón Fairbairn                                 Jon.Fairbairn at cl.cam.ac.uk





More information about the Haskell-Cafe mailing list