简体   繁体   English

Haskell的“功能”在哪里?

[英]Where is Haskell's if' function?

If you use pointfree on the code \\btf -> if b then t else f , the answer you get is if' . 如果你在代码\\btf -> if b then t else f pointfree上使用pointfree \\btf -> if b then t else f ,你得到的答案是if'

Where is if' defined? 其中if'定义?

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 ). 值得一提的是, if'函数存在于4.7版以后的base ,但它被称为bool (带有either maybe样式)。

bool :: a -> a -> Bool -> a
bool f _ False = f
bool _ t True  = t

is defined in Data.Bool . Data.Bool定义。

According to Hayoo , it is defined in the following three packages: 根据Hayoo的说法 ,它在以下三个包中定义:

if' :: Bool -> a -> a -> a
  1. utility-ht - Data.Bool.HT utility-ht - Data.Bool.HT

    if-then-else as function. if-then-else作为函数。

    Example: 例:

     if' (even n) "even" $ if' (isPrime n) "prime" $ "boring" 
  2. plailude - Plailude plailude - Plailude

    If True then the first value, else the second. 如果为True第一个值,否则为第二个值。

  3. CLASE - Data.Cursor.CLASE.Util CLASE - Data.Cursor.CLASE.Util

The two main search engines for Haskell that I know of are Hoogle and Hayoo . 我知道Haskell的两个主要搜索引擎是HoogleHayoo

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM