值得一提的是,该if'函数base自4.7版本开始存在,但它被调用bool(带有either和的样式maybe).
bool :: a -> a -> Bool -> a
bool f _ False = f
bool _ t True  = t
定义于Data.Bool.
根据Hayoo 的说法,它定义在以下三个包中:
if' :: Bool -> a -> a -> a
if-then-else作为函数。
例子:
if' (even n) "even" $
if' (isPrime n) "prime" $
"boring"
如果True则为第一个值,否则为第二个值。
据我所知,Haskell 的两个主要搜索引擎是Hoogle和Hayoo。