Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is Haskell's if' function?

Tags:

haskell

If you use pointfree on the code \b t f -> if b then t else f, the answer you get is if'.

Where is if' defined?

like image 204
Ana Avatar asked Apr 18 '15 03:04

Ana


2 Answers

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.

like image 118
kqr Avatar answered Oct 13 '22 01:10

kqr


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.

like image 30
Aadit M Shah Avatar answered Oct 13 '22 00:10

Aadit M Shah