Type classes (and instances) for things that are like Booleans.
The names of methods in
Boolean clash with the standard Prelude,
so you probably want to inport the Prelude hiding these three
names (since the class methods do the same thing, but with more
general type signatures).
Please note the following points:
- This module imports Control.Monad.Instances, which brings
Monadinstances into scope.
- Among other things, a monad instance for functions is brought
into scope. This, combined with the
Booleaninstance for monads, causes any function that returns a
Booleanto become a
Booleanitself. This allows you to write constructions such as
(> 5) && (< 9), which has the obvious meaning.
- Another interesting consequence of the
Booleaninstance for monads is that
Boolean. You can use this to implement 3-value logic ("true", "false" and "other"), with
Nothingimplementing "other". Any logical operations yield
Nothingunless all arguments are
Justsomething. (This is usually the behaviour you want.)
Typeclass for things that have true and false values.
Typeclass for things that support Boolean operators.
Logical-AND of two values.
Logical-OR of two values. (Inclusive-OR.)
Logical-NOT of two values. (Logical inverse.)
Exclusive-OR (XOR). There is a default implementation, but you can override it for efficiency if desired.