[Haskell-cafe] Lambda-case / lambda-if

Richard O'Keefe ok at cs.otago.ac.nz
Mon Oct 4 17:11:04 EDT 2010


On 4/10/2010, at 8:30 PM, Ketil Malde wrote:
> 
>> Prelude> (case of 1 -> "One"; _ -> "Not-one") 1
>> "One"
>> Prelude> :q
> 
> "case of" looks a bit weird, but I like the points brought up about
> avoiding to name a one-use variable (e.g., getArgs >>= case of ...)
> AFACS, this isn't easily implemented in Haskell either.

Erlang manages fine with multiclause 'fun':

	(fun (1) -> "One" ; (_) -> "Not-one" end)(1)

ML manages fine with multiclause 'fn':

	(fn 1 => "one" | _ => "not-one")(1)

In both cases, the same notation is used for multiclause lambda as
for single clause lambda.  It seems excessively ugly to use
completely different notation depending on the number of alternatives,
especially when one of the notations has another, much more common,
and distinct usage.



More information about the Haskell-Cafe mailing list