[Haskell-cafe] Lambda-case / lambda-if
Richard O'Keefe
ok at cs.otago.ac.nz
Mon Oct 4 20:35:51 EDT 2010
On 5/10/2010, at 12:49 PM, Donn Cave wrote:
> Just to be sure, are you saying, rather than
>
> case of
> 1 -> f
> 2 -> g
>
> you'd like to see \ support pattern matching etc. like named functions -
>
> \ 1 -> f
> 2 -> g
Absolutely. For the record, lambda DOES support pattern matching
(Haskell 2010 report, section 3.3
lexp -> \ apat1 ... apatn -> exp
Lambda abstractions are written \ p1 ... pn -> e where
the pi are _patterns_.
)
To repeat, the analogues in SML and Erlang *do* support multiple
clauses (as well as pattern matching) and the failure of Haskell
lambdas to do so has always seemed like a weird restriction in a
language that's usually free of weird restrictions.
'case of' is terminally cute. I dare say its inventor felt
extremely proud of hacking it in, but it's the kind of thing
that will have admirers swearing in frustration when they get
tripped up by it yet again, and detractors sniggering.
I'd prefer to see something like
\ 1 -> f
| 2 -> g
but I'm sure something could be worked out.
More information about the Haskell-Cafe
mailing list