[Haskell-cafe] Lambda-case / lambda-if
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
> Presumably, this extends to
>> Prelude> (if False then else "Cafe") "Haskell"
>> Prelude> (if then "Haskell" else) False "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