|
|
|
Description |
This module provides a data constructor which lifts any type into a
boolean algebra and some operations on said lifted type.
|
|
Synopsis |
|
|
|
Documentation |
|
data Boolean a |
Constructors | | Instances | |
|
|
simplifyBoolean :: Bool -> Boolean a -> Boolean a |
very safe simplification routine. This will never duplicate terms
or change the order terms occur in the formula, so is safe to use even
when bottom is present.
what it does is:
- removes double negatives
- evaluates constant terms
- removes manifest tautologies
- flattens and of and, or of or
- flattens single element terms
if the first argument is true, it also uses de morgan's laws to ensure
BoolNot may only occur as the parent of a BoolJust. This may allow
additional flattening and simplification, but may increase the number of
negations performed and change the ratio between ands and ors done. It does
not affect term order either way.
|
|
showBoolean :: (a -> String) -> Boolean a -> String |
|
evaluate :: BooleanAlgebra r => (a -> r) -> Boolean a -> r |
evalute Boolean given a function to evaluate its primitives
|
|
evaluateM :: (Monad m, BooleanAlgebra r) => (a -> m r) -> Boolean a -> m r |
evalute Boolean given a monadic function to evaluate its primitives
|
|
parseBoolean' |
:: Parser s | parser for whitespace
| -> Parser t | parser for true
| -> Parser f | parser for false
| -> Parser a | parser for a
| -> Parser (Boolean a) | parser for Boolean a
| A parsec routine to parse a 'Boolean a' given a parser for a.
The format is the same as produced by showBoolean:
a ; b - a or b
a b - a and b
!a - not a
( a ) - a
The parser passed as an argument should eat all whitespace after it matches and
ensure its syntax does not conflict with the Boolean syntax.
|
|
|
dropBoolean :: BooleanAlgebra a => Boolean a -> a |
perform the Boolean actions on the underlying type, flattening out the
Boolean wrapper. This is useful for things like wrapping an expensive to
compute predicate for the purposes of optimization.
|
|
Produced by Haddock version 0.8 |