值得一提的是,自版本4.7起,在 base 中已经存在了 if' 函数,但它被称为 bool(与 either 和 maybe 的风格相似)。bool :: a -> a -> Bool -> a bool f _ False = f bool _ t True = t 定义在Data.Bool中。
根据Hayoo,它被定义在以下三个包中: if' :: Bool -> a -> a -> a utility-ht - Data.Bool.HT if-then-else as function. Example: if' (even n) "even" $ if' (isPrime n) "prime" $ "boring" plailude - Plailude If True then the first value, else the second. CLASE - Data.Cursor.CLASE.Util 我知道的两个Haskell主要搜索引擎是Hoogle和Hayoo。
maybe
和either
的构造器一致,它们按照构造函数声明的顺序接收参数。 - chi