cond-0.4.1: Basic conditional and boolean operators with monadic variants.

Data.Algebra.Boolean

Synopsis

# Documentation

class Boolean b whereSource

A class for boolean algebras. Instances of this class are expected to obey all the laws of boolean algebra.

Minimal complete definition: `true` or `false`, `not` or `<-->`, `||` or `&&`.

Methods

true :: bSource

Truth value, defined as the top of the bounded lattice

false :: bSource

False value, defined as the bottom of the bounded lattice.

not :: b -> bSource

Logical negation.

(&&) :: b -> b -> bSource

Logical conjunction. (infxr 3)

(||) :: b -> b -> bSource

Logical inclusive disjunction. (infixr 2)

xor :: b -> b -> bSource

Logical exclusive disjunction. (infixr 1)

(-->) :: b -> b -> bSource

Logical implication. (infixr 1)

(<-->) :: b -> b -> bSource

Logical biconditional. (infixr 1)

and :: Foldable t => t b -> bSource

The logical conjunction of several values.

or :: Foldable t => t b -> bSource

The logical disjunction of several values.

nand :: Foldable t => t b -> bSource

The negated logical conjunction of several values.

``nand` = `not` . `and``

all :: Foldable t => (a -> b) -> t a -> bSource

The logical conjunction of the mapping of a function over several values.

any :: Foldable t => (a -> b) -> t a -> bSource

The logical disjunction of the mapping of a function over several values.

nor :: Foldable t => t b -> bSource

The negated logical disjunction of several values.

``nor` = `not` . `or``

Instances

 Boolean Bool Boolean All Boolean Any Boolean (Dual Bool) Boolean (Endo Bool) (Num a, Bits a) => Boolean (Bitwise a) (Boolean x, Boolean y) => Boolean (x, y)

fromBool :: Boolean b => Bool -> bSource

Injection from `Bool` into a boolean algebra.

newtype Bitwise a Source

A newtype wrapper that derives a `Boolean` instance from any type that is both a `Bits` instance and a `Num` instance, such that boolean logic operations on the `Bitwise` wrapper correspond to bitwise logic operations on the inner type. It should be noted that `false` is defined as `Bitwise` 0 and `true` is defined as `not` `false`.

In addition, a number of other classes are automatically derived from the inner type. These classes were chosen on the basis that many other `Bits` instances defined in base are also instances of these classes.

Constructors

 Bitwise FieldsgetBits :: a

Instances

 Typeable1 Bitwise Bounded a => Bounded (Bitwise a) Enum a => Enum (Bitwise a) Eq a => Eq (Bitwise a) Integral a => Integral (Bitwise a) Data a => Data (Bitwise a) Num a => Num (Bitwise a) Ord a => Ord (Bitwise a) Read a => Read (Bitwise a) Real a => Real (Bitwise a) Show a => Show (Bitwise a) Ix a => Ix (Bitwise a) PrintfArg a => PrintfArg (Bitwise a) Storable a => Storable (Bitwise a) Bits a => Bits (Bitwise a) (Num a, Bits a) => Boolean (Bitwise a)