简体   繁体   中英

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' .

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
  1. utility-ht - Data.Bool.HT

    if-then-else as function.

    Example:

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

    If True then the first value, else the second.

  3. CLASE - Data.Cursor.CLASE.Util

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.

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