| Maintainer | hapytexeu+gh@gmail.com |
|---|---|
| Stability | experimental |
| Portability | POSIX |
| Safe Haskell | Safe |
| Language | Haskell2010 |
Dep.Data.ThreeValue
Description
A module that defines three-value logic, for example used in thruth tables, Karnaugh cards, etc.
Synopsis
- data ThreeValue
- threeValue :: a -> a -> a -> ThreeValue -> a
- toMaybeBool :: ThreeValue -> Maybe Bool
- toChar :: ThreeValue -> Char
- fromBool :: Bool -> ThreeValue
- fromMaybeBool :: Maybe Bool -> ThreeValue
- toUpper :: ThreeValue -> Bool
- toLower :: ThreeValue -> Bool
- opposite :: Opposite a => a -> a
- type ThreeValues = [ThreeValue]
- parseThreeValue :: Stream s m Char => ParsecT s u m ThreeValue
- parseThreeValues :: Stream s m Char => ParsecT s u m ThreeValues
- parseThreeValues1 :: Stream s m Char => ParsecT s u m (NonEmpty ThreeValue)
Define three-value logic
data ThreeValue Source #
A data type that is used if a value can present three logical values: don't care (or don't know); zero; and one.
Constructors
| Zero | The value is zero or false. |
| One | The value is one or true. |
| DontCare | We do not care or do not know the value. |
Instances
Catamorphisms
Arguments
| :: a | The value for |
| -> a | The value for |
| -> a | The value for |
| -> ThreeValue | The value to convert to one of the given values. |
| -> a | The corresponding value. |
Convert the given ThreeValue object to the corresponding value.
This acts as a catamorphism for the ThreeValue type.
Arguments
| :: ThreeValue | The given |
| -> Maybe Bool |
Arguments
| :: ThreeValue | The given |
| -> Char | The corresponding |
Convert the given ThreeValue to a Char that presents the given
value. DontCare is mapped to -; Zero to 0; and One to 1.
Convert to and from a ThreeValue
Arguments
| :: Bool | The given |
| -> ThreeValue | The corresponding |
toUpper :: ThreeValue -> Bool Source #
toLower :: ThreeValue -> Bool Source #
Operators on ThreeValue
Arguments
| :: Opposite a | |
| => a | The given item to determine the opposite from. |
| -> a | The opposite of the given value. |
A function that determines the opposite value.
Type aliasses
type ThreeValues = [ThreeValue] Source #
A type alias for a list of ThreeValue objects.
parseThreeValue :: Stream s m Char => ParsecT s u m ThreeValue Source #
A parser that can parse a single ThreeValue from a Character.
The characters for Zero are 0, f or F;
the characters for Zero are 1, t or T; and
the characters for DontCare are -, d or D,
parseThreeValues :: Stream s m Char => ParsecT s u m ThreeValues Source #
A parser that can parse a (possibly empty) list of ThreeValue
from a Character. The characters for Zero are 0, f or F;
the characters for Zero are 1, t or T; and
the characters for DontCare are -, d or D,
parseThreeValues1 :: Stream s m Char => ParsecT s u m (NonEmpty ThreeValue) Source #