[Haskell-cafe] Lambda-case / lambda-if
ketil at malde.org
Mon Oct 4 03:30:48 EDT 2010
Max Bolingbroke <batterseapower at hotmail.com> writes:
>  http://hackage.haskell.org/trac/haskell-prime/ticket/41
I tried to find anything about lambda-if in there, but failed (Trac and
I aren't on very friendly terms, so it's probably my fault). Is there
more information about the rationale and use cases for this?
> Prelude> (if then "Haskell" else "Cafe") False
Presumably, this extends to
> Prelude> (if False then else "Cafe") "Haskell"
> Prelude> (if then "Haskell" else) False "Cafe"
My gut reaction is that this doesn't buy a whole lot, and that it is
verbose and not very readable. Any examples where this is a win?
> Prelude> (case of 1 -> "One"; _ -> "Not-one") 1
> 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.
If I haven't seen further, it is by standing in the footprints of giants
More information about the Haskell-Cafe