Safe Haskell | None |
---|
LogicGrowsOnTrees.Utils.PerfectTree
Description
This modules contains utility functions for constructing perfect trees for use in some of the tests and examples.
- perfectTree :: MonadPlus m => α -> Word -> Word -> m α
- trivialPerfectTree :: MonadPlus m => Word -> Word -> m WordSum
- numberOfLeaves :: Word -> Word -> Word
- newtype Arity = Arity {}
- data ArityAndDepth = ArityAndDepth {}
- makeArityAndDepthTermAtPositions :: Int -> Int -> Term ArityAndDepth
- formArityAndDepth :: Arity -> Word -> ArityAndDepth
Tree generators
Arguments
:: MonadPlus m | |
=> α | the value to place at the leaves |
-> Word | the arity of the tree (i.e., number of branches at each internal node) |
-> Word | the depth of the tree |
-> m α |
Generate a perfectly balanced tree with the given leaf value, arity, and leaf.
Arguments
:: MonadPlus m | |
=> Word | the arity of the tree (i.e., number of branches at each internal node) |
-> Word | the depth of the tree |
-> m WordSum |
Like perfectTree
but with WordSum 1
at the leaves.
Arity and depth parameters
Newtype wrapper for arities that has an ArgVal
instance that enforces that
the arity be at least 2.
data ArityAndDepth Source
Datatype representing the arity and depth of a tree, used for command line
argument processing (see makeArityAndDepthTermAtPositions
).
Constructors
ArityAndDepth | |
Instances
makeArityAndDepthTermAtPositionsSource
Arguments
:: Int | the position of the arity parameter in the command line |
-> Int | the position of the depth parameter in the command line |
-> Term ArityAndDepth |
Constructs a configuration term that expects the arity and depth to be at the given command line argument positions.
formArityAndDepth :: Arity -> Word -> ArityAndDepthSource
A convenience function used when you have an value of type Arity
for the
arity of the tree rather than a value of type Word
and want to construct
a value of type ArityAndDepth
.