utility-ht-0.0.14: Various small helper functions for Lists, Maybes, Tuples, Functions

Safe Haskell | Safe
Language | Haskell98

Data.Bool.HT

Synopsis

- if' :: Bool -> a -> a -> a
- ifThenElse :: Bool -> a -> a -> a
- select :: a -> [(Bool, a)] -> a
- (?:) :: Bool -> (a, a) -> a
- implies :: Bool -> Bool -> Bool

# Documentation

if' :: Bool -> a -> a -> a Source #

`if-then-else` as function.

Example:

    if' (even n) "even" $
    if' (isPrime n) "prime" $
    "boring"

ifThenElse :: Bool -> a -> a -> a Source #

The same as `if'`, but the name is chosen such that it can be used for GHC-7.0's rebindable if-then-else syntax.

select :: a -> [(Bool, a)] -> a Source #

From a list of expressions choose the one, whose condition is true.

Example:

    select "boring" $
      (even n, "even") :
      (isPrime n, "prime") :
      []

(?:) :: Bool -> (a, a) -> a infixr 1 Source #

Like the `?` operator of the C progamming language. Example: `bool ?: ("yes", "no")`.

implies :: Bool -> Bool -> Bool infixr 1 Source #

Logical operator for implication.

Funnily because of the ordering of `Bool` it holds `implies == (<=)`.