Data.Boolean
Description
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).
An interesting consequence of the Boolean instance for monads is
that Maybe Bool is a Boolean. You can use this to implement
3-value logic ("true", "false" and "other"), with Nothing
implementing "other". Any logical operations yield Nothing
unless all arguments are Just something. (This is usually the
behaviour you want.)
Documentation
Typeclass for things that have true and false values.
Instances:
- Normal
Boolvalues (obviously). - Any function that yields a
BoolValueas its result. (For example,trueis just a constant function that always returns a truth value, regardless of its input.) - Any monadic action that yields a
BoolValueas its result. (This is justreturnapplied to the appropriateBoolValue.)
Typeclass for things that support Boolean operators.
Instances:
- Normal
Boolvalues (obviously). - Any function that returns a
Boolean. (The result is a new function that runs the old function(s) and applies the appropriate operator to the result(s).) - Any monadic action that returns a
Boolean. (Again, the result is a new action that runs the existing action(s) and applies the appropriate operator to the result(s).)
Methods
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.