[Haskell-cafe] Lambda-case / lambda-if
Christopher Done
chrisdone at googlemail.com
Mon Oct 4 06:05:55 EDT 2010
On 4 October 2010 10:55, Bulat Ziganshin <bulat.ziganshin at gmail.com> wrote:
> Hello Ketil,
>
> Monday, October 4, 2010, 11:30:48 AM, you wrote:
>>> Prelude> (if then "Haskell" else "Cafe") False
>
> lambda-if is easily implemented in terms of usual functions.
> and we even have one named bool:
>
> bool: Bool -> a -> a -> a
I agree, in fact I have bool here:
http://hackage.haskell.org/packages/archive/higherorder/0.0/doc/html/Data-Bool-Higher.html
And the corresponding other types:
bool :: (a -> b) -> (a -> b) -> (a -> Bool) -> a -> b
list :: b -> ([a] -> b) -> [a] -> b
maybe :: b -> (a -> b) -> Maybe a -> b
But the case is especially useful for pattern matching.
More information about the Haskell-Cafe
mailing list