cond-0.5.1: Basic conditional and boolean operators with monadic variants.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Algebra.Boolean

Synopsis

Documentation

class Boolean b where Source #

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 (<-->, false), || or &&.

Minimal complete definition

(false | true), (not | (<-->), false), ((||) | (&&))

Methods

true :: b Source #

Truth value, defined as the top of the bounded lattice

false :: b Source #

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

not :: b -> b Source #

Logical negation.

(&&) :: b -> b -> b infixr 3 Source #

Logical conjunction. (infixr 3)

(||) :: b -> b -> b infixr 2 Source #

Logical inclusive disjunction. (infixr 2)

xor :: b -> b -> b infixr 1 Source #

Logical exclusive disjunction. (infixr 1)

(-->) :: b -> b -> b infixr 1 Source #

Logical implication. (infixr 1)

(<-->) :: b -> b -> b infixr 1 Source #

Logical biconditional. (infixr 1)

Instances

Instances details
Boolean All Source #

Could be done via `deriving via` from GHC8.6.1 onwards

Instance details

Defined in Data.Algebra.Boolean

Methods

true :: All Source #

false :: All Source #

not :: All -> All Source #

(&&) :: All -> All -> All Source #

(||) :: All -> All -> All Source #

xor :: All -> All -> All Source #

(-->) :: All -> All -> All Source #

(<-->) :: All -> All -> All Source #

Boolean Any Source #

Could be done via `deriving via` from GHC8.6.1 onwards

Instance details

Defined in Data.Algebra.Boolean

Methods

true :: Any Source #

false :: Any Source #

not :: Any -> Any Source #

(&&) :: Any -> Any -> Any Source #

(||) :: Any -> Any -> Any Source #

xor :: Any -> Any -> Any Source #

(-->) :: Any -> Any -> Any Source #

(<-->) :: Any -> Any -> Any Source #

Boolean () Source #

The trivial boolean algebra

Instance details

Defined in Data.Algebra.Boolean

Methods

true :: () Source #

false :: () Source #

not :: () -> () Source #

(&&) :: () -> () -> () Source #

(||) :: () -> () -> () Source #

xor :: () -> () -> () Source #

(-->) :: () -> () -> () Source #

(<-->) :: () -> () -> () Source #

Boolean Bool Source # 
Instance details

Defined in Data.Algebra.Boolean

Boolean (Dual Bool) Source #

Could be done via `deriving via` from GHC8.6.1 onwards

Instance details

Defined in Data.Algebra.Boolean

Boolean a => Boolean (Endo a) Source #

Could be done via `deriving via` from GHC8.6.1 onwards

Instance details

Defined in Data.Algebra.Boolean

Methods

true :: Endo a Source #

false :: Endo a Source #

not :: Endo a -> Endo a Source #

(&&) :: Endo a -> Endo a -> Endo a Source #

(||) :: Endo a -> Endo a -> Endo a Source #

xor :: Endo a -> Endo a -> Endo a Source #

(-->) :: Endo a -> Endo a -> Endo a Source #

(<-->) :: Endo a -> Endo a -> Endo a Source #

(Num a, Bits a) => Boolean (Bitwise a) Source # 
Instance details

Defined in Data.Algebra.Boolean

Boolean a => Boolean (Opp a) Source #

Opposite boolean algebra: exchanges true and false, and and and or, etc

Instance details

Defined in Data.Algebra.Boolean

Methods

true :: Opp a Source #

false :: Opp a Source #

not :: Opp a -> Opp a Source #

(&&) :: Opp a -> Opp a -> Opp a Source #

(||) :: Opp a -> Opp a -> Opp a Source #

xor :: Opp a -> Opp a -> Opp a Source #

(-->) :: Opp a -> Opp a -> Opp a Source #

(<-->) :: Opp a -> Opp a -> Opp a Source #

Boolean b => Boolean (a -> b) Source #

Pointwise boolean algebra.

Instance details

Defined in Data.Algebra.Boolean

Methods

true :: a -> b Source #

false :: a -> b Source #

not :: (a -> b) -> a -> b Source #

(&&) :: (a -> b) -> (a -> b) -> a -> b Source #

(||) :: (a -> b) -> (a -> b) -> a -> b Source #

xor :: (a -> b) -> (a -> b) -> a -> b Source #

(-->) :: (a -> b) -> (a -> b) -> a -> b Source #

(<-->) :: (a -> b) -> (a -> b) -> a -> b Source #

(Boolean x, Boolean y) => Boolean (x, y) Source # 
Instance details

Defined in Data.Algebra.Boolean

Methods

true :: (x, y) Source #

false :: (x, y) Source #

not :: (x, y) -> (x, y) Source #

(&&) :: (x, y) -> (x, y) -> (x, y) Source #

(||) :: (x, y) -> (x, y) -> (x, y) Source #

xor :: (x, y) -> (x, y) -> (x, y) Source #

(-->) :: (x, y) -> (x, y) -> (x, y) Source #

(<-->) :: (x, y) -> (x, y) -> (x, y) Source #

(Boolean x, Boolean y, Boolean z) => Boolean (x, y, z) Source # 
Instance details

Defined in Data.Algebra.Boolean

Methods

true :: (x, y, z) Source #

false :: (x, y, z) Source #

not :: (x, y, z) -> (x, y, z) Source #

(&&) :: (x, y, z) -> (x, y, z) -> (x, y, z) Source #

(||) :: (x, y, z) -> (x, y, z) -> (x, y, z) Source #

xor :: (x, y, z) -> (x, y, z) -> (x, y, z) Source #

(-->) :: (x, y, z) -> (x, y, z) -> (x, y, z) Source #

(<-->) :: (x, y, z) -> (x, y, z) -> (x, y, z) Source #

fromBool :: Boolean b => Bool -> b Source #

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 

Fields

Instances

Instances details
Data a => Data (Bitwise a) Source # 
Instance details

Defined in Data.Algebra.Boolean

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Bitwise a -> c (Bitwise a) #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Bitwise a) #

toConstr :: Bitwise a -> Constr #

dataTypeOf :: Bitwise a -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Bitwise a)) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Bitwise a)) #

gmapT :: (forall b. Data b => b -> b) -> Bitwise a -> Bitwise a #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Bitwise a -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Bitwise a -> r #

gmapQ :: (forall d. Data d => d -> u) -> Bitwise a -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Bitwise a -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Bitwise a -> m (Bitwise a) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Bitwise a -> m (Bitwise a) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Bitwise a -> m (Bitwise a) #

Storable a => Storable (Bitwise a) Source # 
Instance details

Defined in Data.Algebra.Boolean

Methods

sizeOf :: Bitwise a -> Int #

alignment :: Bitwise a -> Int #

peekElemOff :: Ptr (Bitwise a) -> Int -> IO (Bitwise a) #

pokeElemOff :: Ptr (Bitwise a) -> Int -> Bitwise a -> IO () #

peekByteOff :: Ptr b -> Int -> IO (Bitwise a) #

pokeByteOff :: Ptr b -> Int -> Bitwise a -> IO () #

peek :: Ptr (Bitwise a) -> IO (Bitwise a) #

poke :: Ptr (Bitwise a) -> Bitwise a -> IO () #

Bits a => Bits (Bitwise a) Source # 
Instance details

Defined in Data.Algebra.Boolean

Bounded a => Bounded (Bitwise a) Source # 
Instance details

Defined in Data.Algebra.Boolean

Enum a => Enum (Bitwise a) Source # 
Instance details

Defined in Data.Algebra.Boolean

Methods

succ :: Bitwise a -> Bitwise a #

pred :: Bitwise a -> Bitwise a #

toEnum :: Int -> Bitwise a #

fromEnum :: Bitwise a -> Int #

enumFrom :: Bitwise a -> [Bitwise a] #

enumFromThen :: Bitwise a -> Bitwise a -> [Bitwise a] #

enumFromTo :: Bitwise a -> Bitwise a -> [Bitwise a] #

enumFromThenTo :: Bitwise a -> Bitwise a -> Bitwise a -> [Bitwise a] #

Ix a => Ix (Bitwise a) Source # 
Instance details

Defined in Data.Algebra.Boolean

Methods

range :: (Bitwise a, Bitwise a) -> [Bitwise a] #

index :: (Bitwise a, Bitwise a) -> Bitwise a -> Int #

unsafeIndex :: (Bitwise a, Bitwise a) -> Bitwise a -> Int #

inRange :: (Bitwise a, Bitwise a) -> Bitwise a -> Bool #

rangeSize :: (Bitwise a, Bitwise a) -> Int #

unsafeRangeSize :: (Bitwise a, Bitwise a) -> Int #

Num a => Num (Bitwise a) Source # 
Instance details

Defined in Data.Algebra.Boolean

Methods

(+) :: Bitwise a -> Bitwise a -> Bitwise a #

(-) :: Bitwise a -> Bitwise a -> Bitwise a #

(*) :: Bitwise a -> Bitwise a -> Bitwise a #

negate :: Bitwise a -> Bitwise a #

abs :: Bitwise a -> Bitwise a #

signum :: Bitwise a -> Bitwise a #

fromInteger :: Integer -> Bitwise a #

Read a => Read (Bitwise a) Source # 
Instance details

Defined in Data.Algebra.Boolean

Integral a => Integral (Bitwise a) Source # 
Instance details

Defined in Data.Algebra.Boolean

Methods

quot :: Bitwise a -> Bitwise a -> Bitwise a #

rem :: Bitwise a -> Bitwise a -> Bitwise a #

div :: Bitwise a -> Bitwise a -> Bitwise a #

mod :: Bitwise a -> Bitwise a -> Bitwise a #

quotRem :: Bitwise a -> Bitwise a -> (Bitwise a, Bitwise a) #

divMod :: Bitwise a -> Bitwise a -> (Bitwise a, Bitwise a) #

toInteger :: Bitwise a -> Integer #

Real a => Real (Bitwise a) Source # 
Instance details

Defined in Data.Algebra.Boolean

Methods

toRational :: Bitwise a -> Rational #

Show a => Show (Bitwise a) Source # 
Instance details

Defined in Data.Algebra.Boolean

Methods

showsPrec :: Int -> Bitwise a -> ShowS #

show :: Bitwise a -> String #

showList :: [Bitwise a] -> ShowS #

PrintfArg a => PrintfArg (Bitwise a) Source # 
Instance details

Defined in Data.Algebra.Boolean

(Num a, Bits a) => Boolean (Bitwise a) Source # 
Instance details

Defined in Data.Algebra.Boolean

Eq a => Eq (Bitwise a) Source # 
Instance details

Defined in Data.Algebra.Boolean

Methods

(==) :: Bitwise a -> Bitwise a -> Bool #

(/=) :: Bitwise a -> Bitwise a -> Bool #

Ord a => Ord (Bitwise a) Source # 
Instance details

Defined in Data.Algebra.Boolean

Methods

compare :: Bitwise a -> Bitwise a -> Ordering #

(<) :: Bitwise a -> Bitwise a -> Bool #

(<=) :: Bitwise a -> Bitwise a -> Bool #

(>) :: Bitwise a -> Bitwise a -> Bool #

(>=) :: Bitwise a -> Bitwise a -> Bool #

max :: Bitwise a -> Bitwise a -> Bitwise a #

min :: Bitwise a -> Bitwise a -> Bitwise a #

and :: (Boolean b, Foldable t) => t b -> b Source #

The logical conjunction of several values.

or :: (Boolean b, Foldable t) => t b -> b Source #

The logical disjunction of several values.

nand :: (Boolean b, Foldable t) => t b -> b Source #

The negated logical conjunction of several values.

nand = not . and

nor :: (Boolean b, Foldable t) => t b -> b Source #

The negated logical disjunction of several values.

nor = not . or

any :: (Boolean b, Foldable t) => (a -> b) -> t a -> b Source #

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

all :: (Boolean b, Foldable t) => (a -> b) -> t a -> b Source #

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

newtype Opp a Source #

Constructors

Opp 

Fields

Instances

Instances details
Show a => Show (Opp a) Source # 
Instance details

Defined in Data.Algebra.Boolean

Methods

showsPrec :: Int -> Opp a -> ShowS #

show :: Opp a -> String #

showList :: [Opp a] -> ShowS #

Boolean a => Boolean (Opp a) Source #

Opposite boolean algebra: exchanges true and false, and and and or, etc

Instance details

Defined in Data.Algebra.Boolean

Methods

true :: Opp a Source #

false :: Opp a Source #

not :: Opp a -> Opp a Source #

(&&) :: Opp a -> Opp a -> Opp a Source #

(||) :: Opp a -> Opp a -> Opp a Source #

xor :: Opp a -> Opp a -> Opp a Source #

(-->) :: Opp a -> Opp a -> Opp a Source #

(<-->) :: Opp a -> Opp a -> Opp a Source #

Eq a => Eq (Opp a) Source # 
Instance details

Defined in Data.Algebra.Boolean

Methods

(==) :: Opp a -> Opp a -> Bool #

(/=) :: Opp a -> Opp a -> Bool #

Ord a => Ord (Opp a) Source # 
Instance details

Defined in Data.Algebra.Boolean

Methods

compare :: Opp a -> Opp a -> Ordering #

(<) :: Opp a -> Opp a -> Bool #

(<=) :: Opp a -> Opp a -> Bool #

(>) :: Opp a -> Opp a -> Bool #

(>=) :: Opp a -> Opp a -> Bool #

max :: Opp a -> Opp a -> Opp a #

min :: Opp a -> Opp a -> Opp a #

newtype AnyB b Source #

A boolean algebra regarded as a monoid under disjunction

Constructors

AnyB 

Fields

Instances

Instances details
Boolean b => Monoid (AnyB b) Source # 
Instance details

Defined in Data.Algebra.Boolean

Methods

mempty :: AnyB b #

mappend :: AnyB b -> AnyB b -> AnyB b #

mconcat :: [AnyB b] -> AnyB b #

Boolean b => Semigroup (AnyB b) Source # 
Instance details

Defined in Data.Algebra.Boolean

Methods

(<>) :: AnyB b -> AnyB b -> AnyB b #

sconcat :: NonEmpty (AnyB b) -> AnyB b #

stimes :: Integral b0 => b0 -> AnyB b -> AnyB b #

Show b => Show (AnyB b) Source # 
Instance details

Defined in Data.Algebra.Boolean

Methods

showsPrec :: Int -> AnyB b -> ShowS #

show :: AnyB b -> String #

showList :: [AnyB b] -> ShowS #

Eq b => Eq (AnyB b) Source # 
Instance details

Defined in Data.Algebra.Boolean

Methods

(==) :: AnyB b -> AnyB b -> Bool #

(/=) :: AnyB b -> AnyB b -> Bool #

Ord b => Ord (AnyB b) Source # 
Instance details

Defined in Data.Algebra.Boolean

Methods

compare :: AnyB b -> AnyB b -> Ordering #

(<) :: AnyB b -> AnyB b -> Bool #

(<=) :: AnyB b -> AnyB b -> Bool #

(>) :: AnyB b -> AnyB b -> Bool #

(>=) :: AnyB b -> AnyB b -> Bool #

max :: AnyB b -> AnyB b -> AnyB b #

min :: AnyB b -> AnyB b -> AnyB b #

newtype AllB b Source #

A boolean algebra regarded as a monoid under conjunction

Constructors

AllB 

Fields

Instances

Instances details
Boolean b => Monoid (AllB b) Source # 
Instance details

Defined in Data.Algebra.Boolean

Methods

mempty :: AllB b #

mappend :: AllB b -> AllB b -> AllB b #

mconcat :: [AllB b] -> AllB b #

Boolean b => Semigroup (AllB b) Source # 
Instance details

Defined in Data.Algebra.Boolean

Methods

(<>) :: AllB b -> AllB b -> AllB b #

sconcat :: NonEmpty (AllB b) -> AllB b #

stimes :: Integral b0 => b0 -> AllB b -> AllB b #

Show b => Show (AllB b) Source # 
Instance details

Defined in Data.Algebra.Boolean

Methods

showsPrec :: Int -> AllB b -> ShowS #

show :: AllB b -> String #

showList :: [AllB b] -> ShowS #

Eq b => Eq (AllB b) Source # 
Instance details

Defined in Data.Algebra.Boolean

Methods

(==) :: AllB b -> AllB b -> Bool #

(/=) :: AllB b -> AllB b -> Bool #

Ord b => Ord (AllB b) Source # 
Instance details

Defined in Data.Algebra.Boolean

Methods

compare :: AllB b -> AllB b -> Ordering #

(<) :: AllB b -> AllB b -> Bool #

(<=) :: AllB b -> AllB b -> Bool #

(>) :: AllB b -> AllB b -> Bool #

(>=) :: AllB b -> AllB b -> Bool #

max :: AllB b -> AllB b -> AllB b #

min :: AllB b -> AllB b -> AllB b #

newtype XorB b Source #

A boolean algebra regarded as a monoid under exclusive or

Constructors

XorB 

Fields

Instances

Instances details
Boolean b => Monoid (XorB b) Source # 
Instance details

Defined in Data.Algebra.Boolean

Methods

mempty :: XorB b #

mappend :: XorB b -> XorB b -> XorB b #

mconcat :: [XorB b] -> XorB b #

Boolean b => Semigroup (XorB b) Source # 
Instance details

Defined in Data.Algebra.Boolean

Methods

(<>) :: XorB b -> XorB b -> XorB b #

sconcat :: NonEmpty (XorB b) -> XorB b #

stimes :: Integral b0 => b0 -> XorB b -> XorB b #

Show b => Show (XorB b) Source # 
Instance details

Defined in Data.Algebra.Boolean

Methods

showsPrec :: Int -> XorB b -> ShowS #

show :: XorB b -> String #

showList :: [XorB b] -> ShowS #

Eq b => Eq (XorB b) Source # 
Instance details

Defined in Data.Algebra.Boolean

Methods

(==) :: XorB b -> XorB b -> Bool #

(/=) :: XorB b -> XorB b -> Bool #

Ord b => Ord (XorB b) Source # 
Instance details

Defined in Data.Algebra.Boolean

Methods

compare :: XorB b -> XorB b -> Ordering #

(<) :: XorB b -> XorB b -> Bool #

(<=) :: XorB b -> XorB b -> Bool #

(>) :: XorB b -> XorB b -> Bool #

(>=) :: XorB b -> XorB b -> Bool #

max :: XorB b -> XorB b -> XorB b #

min :: XorB b -> XorB b -> XorB b #

newtype EquivB b Source #

A boolean algebra regarded as a monoid under equivalence

Constructors

EquivB 

Fields

Instances

Instances details
Boolean b => Monoid (EquivB b) Source # 
Instance details

Defined in Data.Algebra.Boolean

Methods

mempty :: EquivB b #

mappend :: EquivB b -> EquivB b -> EquivB b #

mconcat :: [EquivB b] -> EquivB b #

Boolean b => Semigroup (EquivB b) Source # 
Instance details

Defined in Data.Algebra.Boolean

Methods

(<>) :: EquivB b -> EquivB b -> EquivB b #

sconcat :: NonEmpty (EquivB b) -> EquivB b #

stimes :: Integral b0 => b0 -> EquivB b -> EquivB b #

Show b => Show (EquivB b) Source # 
Instance details

Defined in Data.Algebra.Boolean

Methods

showsPrec :: Int -> EquivB b -> ShowS #

show :: EquivB b -> String #

showList :: [EquivB b] -> ShowS #

Eq b => Eq (EquivB b) Source # 
Instance details

Defined in Data.Algebra.Boolean

Methods

(==) :: EquivB b -> EquivB b -> Bool #

(/=) :: EquivB b -> EquivB b -> Bool #

Ord b => Ord (EquivB b) Source # 
Instance details

Defined in Data.Algebra.Boolean

Methods

compare :: EquivB b -> EquivB b -> Ordering #

(<) :: EquivB b -> EquivB b -> Bool #

(<=) :: EquivB b -> EquivB b -> Bool #

(>) :: EquivB b -> EquivB b -> Bool #

(>=) :: EquivB b -> EquivB b -> Bool #

max :: EquivB b -> EquivB b -> EquivB b #

min :: EquivB b -> EquivB b -> EquivB b #