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

Donn Cave donn at avvanta.com
Mon Oct 4 11:04:21 EDT 2010

Quoth Ketil Malde <ketil at malde.org>,
> Max Bolingbroke <batterseapower at hotmail.com> writes:
>> 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?

I think you're not the first to ask.  Just out of curiosity, or is
there a use for these variations?

The reason for the initially proposed construct seems clear enough
to me, it's very much like `case'.  The difference is that of course
it's limited to True & False, so would naturally be used more with
more `composition', e.g.

  getargs >>= if then beTrue else beFalse . (==) ["-t"]

... and thus will quickly become unreadable with less trivial components.


More information about the Haskell-Cafe mailing list