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

Ketil Malde ketil at malde.org
Mon Oct 4 03:30:48 EDT 2010


Max Bolingbroke <batterseapower at hotmail.com> writes:

> [1] 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
> "Cafe"

Presumably, this extends to 

> Prelude> (if False then else "Cafe") "Haskell"
> "Cafe"

and

> Prelude> (if then "Haskell" else) False "Cafe"
> "Cafe"

as well?

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
> "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.

-k
-- 
If I haven't seen further, it is by standing in the footprints of giants


More information about the Haskell-Cafe mailing list