| Maintainer | hapytexeu+gh@gmail.com |
|---|---|
| Stability | experimental |
| Portability | POSIX |
| Safe Haskell | Safe |
| Language | Haskell2010 |
Dep.Data.Three
Description
This modules defines a three, a tree-like data structure with a leaf, a node, and a link where both subtrees are the same. This is used to make more compact and efficient representations of a boolean function.
Synopsis
- data Three a
- type ThreePath = [ThreeStep]
- type ThreeStep = ThreeValue
- three :: (a -> b) -> (b -> b) -> (b -> b -> b) -> Three a -> b
- depth :: Three a -> Int
- leftmost :: Three a -> a
- rightmost :: Three a -> a
- flipThree :: Three a -> Three a
- flipAllThree :: Three a -> Three a
- nstep :: NonDeterministicWalkable f step => f a -> step -> [f a]
- apply :: (a -> a) -> ThreePath -> Three (a -> a)
- applyTo :: (a -> a) -> ThreePath -> Three a -> Three a
- wipe :: a -> ThreePath -> Three a -> Three a
- wipeAll :: a -> Three a -> [ThreePath] -> Three a
- children :: ThreePath -> Three a -> [a]
- children' :: ThreePath -> Three a -> [a] -> [a]
- toTraces :: Three a -> [(ThreeValues, a)]
- toTraces' :: Three a -> [(ThreeValues, a)] -> [(ThreeValues, a)]
- toTraces'' :: Three a -> ThreeValues -> [(ThreeValues, a)] -> [(ThreeValues, a)]
Defining a three
A data structure used to specify a mapping from a list of booleans to a value in a more compact way. This datastructure can effectively be used to define a sum of products or a product of sums.
Constructors
| Leaf a | A leaf that contains a single value. |
| Link (Three a) | A link where it means that this variable does not matter but the next one(s) will. |
| Split (Three a) (Three a) | A split where this variable determines the outcome. |
Instances
Paths in a three
type ThreePath = [ThreeStep] Source #
A type of a list (non-deterministic) steps in a Three structure.
type ThreeStep = ThreeValue Source #
A type alias for (non-deterministic) steps in a Three structure.
Catamorphisms
Arguments
| :: Three a | The |
| -> Int | The depth of the given |
Determine the maximum depth of the Three tree.
Arguments
| :: Three a | The |
| -> a | The leftmost item in the given |
Obtain the leftmost item of the Three.
Arguments
| :: Three a | The |
| -> a | The rightmost item in the given |
Obtain the rightmost item of the Three.
Manipulate a Three
Lookups and constructions
Arguments
| :: NonDeterministicWalkable f step | |
| => f a | The given initial state where we make a non-determinstic step. |
| -> step | The step that we make, such step can result in zero, one or more new states. |
| -> [f a] | The list of the possible states with the new step. |
Take a non-deterministic step that can result in multiple outcomes.
Arguments
| :: (a -> a) | The given function to apply for the items that satisfy the given path. |
| -> ThreePath | The given path to use. |
| -> Three (a -> a) | A |
Construct a Three that will apply the given function
for the items that satisfy the given path of three-valued
objects.
Arguments
| :: (a -> a) | The given function to apply to some parts of the |
| -> ThreePath | The given path that specifies what for what parts of the |
| -> Three a | The given |
| -> Three a | The resulting |
Apply the given function to the elements in the given Three that satisfy the given path.
Arguments
| :: a | The given value such that we replace parts of the three with the given |
| -> ThreePath | The given path that specifies what for what parts of the |
| -> Three a | The given |
| -> Three a | The resulting |
Arguments
| :: a | The given element to use when we wipe. |
| -> Three a | The original |
| -> [ThreePath] | The list of paths to wipe. |
| -> Three a | The |
Wipe with the given value all the given ThreePaths.
Retrieve children according to a path
Arguments
| :: ThreePath | The given |
| -> Three a | The given |
| -> [a] | A list of children that satisfy the given |
Obtain the children that satisfy a given ThreePath.
Arguments
| :: ThreePath | The given |
| -> Three a | The given |
| -> [a] | The list of tail elements. |
| -> [a] | The list of children followed by the given list of tail elements. |
Obtain the children that satisfy the given ThreePath.
Convert the Three to an key-value list
Arguments
| :: Three a | |
| -> [(ThreeValues, a)] | The list of addresses in *reverse* with the corresponding value. |
Convert the given Three to a list of 2-tuples with as first item the "address" in reverse,
and as second item the value associated with this.
Arguments
| :: Three a | |
| -> [(ThreeValues, a)] | The list of trailing items that can be added at the end. |
| -> [(ThreeValues, a)] | The list of addresses in reverse with the corresponding value. |
Convert the given Three to a list of 2-tuples with as first item the "address" in reverse,
and as second item the value associated with this.
Arguments
| :: Three a | |
| -> ThreeValues | The current address that will be manipulated as we walk through the |
| -> [(ThreeValues, a)] | The list of trailing items that can be added at the end. |
| -> [(ThreeValues, a)] | The list of addresses in reverse with the corresponding value. |
Convert the given Three to a list of 2-tuples with as first item the "address" in reverse,
and as second item the value associated with this.