This library implements some operations to generate search trees for various data types.
The library also provides combinators to support the easy definition of search tree generators for user-defined data types. If a data type is defined by
data T a1 ... an = ... | C t1 ... tn | ....
then one can define a search tree generator for this type by
genT gena1 ... genan = ... ||| genCons<n> C gen_t1 ... gen_t1 ||| ...
where gen_ti
denotes the search tree generator for type ti
.
For instance, a search tree generator for the type
data Tree a = Leaf a | Node [Tree a]
can be defined by
genTree gena = genCons1 Leaf gena ||| genCons1 Node (genList (genTree gena))
Author: Michael Hanus
Version: December 2018
(|||)
:: SearchTree a -> SearchTree a -> SearchTree a
Constructs an alternative of two search trees. |
genCons0
:: a -> SearchTree a
Constructs a generator for a nullary constructor. |
genCons1
:: (a -> b) -> SearchTree a -> SearchTree b
Constructs a generator for a unary constructor where the generator for the argument type is provided. |
genCons2
:: (a -> b -> c) -> SearchTree a -> SearchTree b -> SearchTree c
Constructs a generator for a binary constructor where the generators for the argument types are provided. |
genCons3
:: (a -> b -> c -> d) -> SearchTree a -> SearchTree b -> SearchTree c -> SearchTree d
Constructs a generator for a ternary constructor where the generators for the argument types are provided. |
genCons4
:: (a -> b -> c -> d -> e) -> SearchTree a -> SearchTree b -> SearchTree c -> SearchTree d -> SearchTree e
Constructs a generator for a constructor of arity 4 where the generators for the argument types are provided. |
genCons5
:: (a -> b -> c -> d -> e -> f) -> SearchTree a -> SearchTree b -> SearchTree c -> SearchTree d -> SearchTree e -> SearchTree f
Constructs a generator for a constructor of arity 5 where the generators for the argument types are provided. |
genNat
:: SearchTree Int
Generates a search tree for positive natural numbers: |
genInt
:: SearchTree Int
Generates a search tree for integer values. |
genFloat
:: SearchTree Float
Generates a search tree for Float values. |
genBool
:: SearchTree Bool
Generates a search tree for Boolean values. |
genChar
:: SearchTree Char
Generates a search tree for character values. |
genList
:: SearchTree a -> SearchTree [a]
Generates a search tree for list values where the search tree for the elements is given as a parameter. |
genMaybe
:: SearchTree a -> SearchTree (Maybe a)
Generates a search tree for Maybe
values where the search tree for
the possible element is given as a parameter.
|
genEither
:: SearchTree a -> SearchTree b -> SearchTree (Either a b)
Generates a search tree for Either
values where the search tree for
the possible elements is given as a parameter.
|
genUnit
:: SearchTree ()
Generates a search tree for the unit values. |
genPair
:: SearchTree a -> SearchTree b -> SearchTree (a,b)
Generates a search tree for pair of values where the search tree generators for the components types are given as parameters. |
genTriple
:: SearchTree a -> SearchTree b -> SearchTree c -> SearchTree (a,b,c)
Generates a search tree for triple of values where the search tree generators for the components types are given as parameters. |
genTuple4
:: SearchTree a -> SearchTree b -> SearchTree c -> SearchTree d -> SearchTree (a,b,c,d)
Generates a search tree for quadruple of values where the search tree generators for the components types are given as parameters. |
genTuple5
:: SearchTree a -> SearchTree b -> SearchTree c -> SearchTree d -> SearchTree e -> SearchTree (a,b,c,d,e)
Generates a search tree for 5-tuple of values where the search tree generators for the components types are given as parameters. |
genOrdering
:: SearchTree Ordering
Generates a search tree for the Ordering
values.
|
Constructs an alternative of two search trees.
|
Constructs a generator for a nullary constructor.
|
Constructs a generator for a unary constructor where the generator for the argument type is provided. |
Constructs a generator for a binary constructor where the generators for the argument types are provided. |
Constructs a generator for a ternary constructor where the generators for the argument types are provided. |
Constructs a generator for a constructor of arity 4 where the generators for the argument types are provided. |
Constructs a generator for a constructor of arity 5 where the generators for the argument types are provided. |
Generates a search tree for positive natural numbers: |
Generates a search tree for integer values. |
Generates a search tree for Float values. |
Generates a search tree for Boolean values.
|
Generates a search tree for character values. In order to obtain readable values, we only generate letters and digits. |
Generates a search tree for list values where the search tree for the elements is given as a parameter. |
Generates a search tree for |
Generates a search tree for |
Generates a search tree for the unit values.
|
Generates a search tree for pair of values where the search tree generators for the components types are given as parameters. |
Generates a search tree for triple of values where the search tree generators for the components types are given as parameters. |
Generates a search tree for quadruple of values where the search tree generators for the components types are given as parameters. |
Generates a search tree for 5-tuple of values where the search tree generators for the components types are given as parameters. |
Generates a search tree for the
|