Boolean-0.0.0: Generalized boolean opsSource codeContentsIndex
Data.Boolean
Stabilityexperimental
Maintainerconal@conal.net
Description

Some classes for generalized boolean operations.

In this design, for if-then-else, equality and inequality tests, the boolean type depends functionally on the value type. This dependency allows the boolean type to be inferred in a conditional expression.

I also tried using a unary type constructor class. The class doesn't work for regular booleans, so generality is lost. Also, we'd probably have to wire class constraints in like: (==*) :: Eq a => f Bool -> f a -> f a -> f a, which disallows situations needing additional constraints, e.g., Show.

Synopsis
class Boolean b where
true :: b
false :: b
notB :: b -> b
(&&*) :: b -> b -> b
(||*) :: b -> b -> b
class Boolean bool => IfB bool a | a -> bool where
ifB :: bool -> a -> a -> a
boolean :: IfB bool a => a -> a -> bool -> a
cond :: (Applicative f, IfB bool a) => f bool -> f a -> f a -> f a
crop :: (Applicative f, Monoid (f a), IfB bool a) => f bool -> f a -> f a
class Boolean bool => EqB bool a | a -> bool where
(==*) :: a -> a -> bool
(/=*) :: a -> a -> bool
class Boolean bool => OrdB bool a | a -> bool where
(<*) :: a -> a -> bool
(>=*) :: a -> a -> bool
(>*) :: a -> a -> bool
(<=*) :: a -> a -> bool
Documentation
class Boolean b whereSource
Generalized boolean class
Methods
true :: bSource
false :: bSource
notB :: b -> bSource
(&&*) :: b -> b -> bSource
(||*) :: b -> b -> bSource
show/hide Instances
Boolean Bool
Boolean bool => Boolean (z -> bool)
class Boolean bool => IfB bool a | a -> bool whereSource
Types with conditionals
Methods
ifB :: bool -> a -> a -> aSource
show/hide Instances
IfB Bool Float
IfB Bool Float
(IfB bool p, IfB bool q) => IfB bool ((,) p q)
(IfB bool p, IfB bool q, IfB bool r) => IfB bool ((,,) p q r)
(IfB bool p, IfB bool q, IfB bool r, IfB bool s) => IfB bool ((,,,) p q r s)
IfB bool a => IfB (z -> bool) (z -> a)
boolean :: IfB bool a => a -> a -> bool -> aSource
Expression-lifted conditional with condition last
cond :: (Applicative f, IfB bool a) => f bool -> f a -> f a -> f aSource
Point-wise conditional
crop :: (Applicative f, Monoid (f a), IfB bool a) => f bool -> f a -> f aSource
Crop a function, filling in mempty where the test yeis false.
class Boolean bool => EqB bool a | a -> bool whereSource
Types with equality. Minimum definition: '(==*)'.
Methods
(==*) :: a -> a -> boolSource
(/=*) :: a -> a -> boolSource
show/hide Instances
EqB Bool Float
EqB Bool Float
EqB bool a => EqB (z -> bool) (z -> a)
class Boolean bool => OrdB bool a | a -> bool whereSource
Types with inequality. Minimum definition: '(<*)'.
Methods
(<*) :: a -> a -> boolSource
(>=*) :: a -> a -> boolSource
(>*) :: a -> a -> boolSource
(<=*) :: a -> a -> boolSource
show/hide Instances
OrdB Bool Float
OrdB Bool Float
OrdB bool a => OrdB (z -> bool) (z -> a)
Produced by Haddock version 2.4.2