If you use pointfree
on the code \\btf -> if b then t else f
, the answer you get is if'
.
Where is if'
defined?
It's worth mentioning that the if'
function exists in base
since version 4.7, but it's called bool
(in style with either
and maybe
).
bool :: a -> a -> Bool -> a
bool f _ False = f
bool _ t True = t
is defined in Data.Bool
.
According to Hayoo , it is defined in the following three packages:
if' :: Bool -> a -> a -> a
if-then-else
as function.
Example:
if' (even n) "even" $ if' (isPrime n) "prime" $ "boring"
If True
then the first value, else the second.
The two main search engines for Haskell that I know of are Hoogle and Hayoo .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.