qcheck/tree
Trees
This module contains functions for creating and manipulating shrink trees.
They are mostly inteded for internal use or “advanced” manual construction of generators. In typical usage, you will probably not need to interact with these functions much, if at all. As such, they are currently mostly undocumented.
In fact, if you are using these functions a lot, file a issue on GitHub and let me know if there are any generator combinators that you’re missing.
There are functions for dealing with the Tree type directly, but they are low-level and you should not need to use them much.
- The Tree type
- new
- return
- map
- map2
- bind
- apply
- collect
- sequence_trees
- option
- to_string
- to_string_with_max_depth
Types
Functions
pub fn collect(tree: Tree(a), f: fn(a) -> b) -> List(b)
Collect values of the tree into a list, while processing them with the
mapping given function f
.
pub fn sequence_trees(l: List(Tree(a))) -> Tree(List(a))
sequence_trees(list_of_trees)
sequences a list of trees into a tree of lists.
pub fn to_string(
tree: Tree(a),
a_to_string: fn(a) -> String,
) -> String
to_string(tree, element_to_string)
converts a tree into an unspecified string representation.
element_to_string
: a function that converts individual elements of the tree to strings.
pub fn to_string_max_depth(
tree: Tree(a),
a_to_string: fn(a) -> String,
max_depth: Int,
) -> String
Like to_string
but with a configurable max_depth
.