Basic Observers
val opaque : _ tProduces an observer that treats all values as equivalent. Random functions generated using this observer will be constant with respect to the value(s) it observes.
val fn : 'a Generator.t -> 'b t -> ('a -> 'b) tProduces an observer that generates random inputs for a given function, calls the function on them, then observes the corresponding outputs.
val map_t : 'key t -> 'data t -> ('key, 'data, 'cmp) Base.Map.t tval set_t : 'elt t -> ('elt, 'cmp) Base.Set.t tval map_tree : 'key t -> 'data t -> ('key, 'data, 'cmp) Base.Map.Using_comparator.Tree.t tval set_tree : 'elt t -> ('elt, 'cmp) Base.Set.Using_comparator.Tree.t tObservers Based on Hash Functions
val of_hash_fold : (Base.Hash.state -> 'a -> Base.Hash.state) -> 'a tCreates an observer that just calls a hash function. This is a good default for most hashable types not covered by the basic observers above.
Modifying Observers
Observers for Recursive Types
Ties the recursive knot to observe recursive types.
For example, here is an observer for binary trees:
let tree_observer leaf_observer =
fixed_point (fun self ->
either leaf_observer (both self self)
|> unmap ~f:(function
| `Leaf leaf -> First leaf
| `Node (l, r) -> Second (l, r)))val of_lazy : 'a t Base.Lazy.t -> 'a tCreates a t that forces the lazy argument as necessary. Can be used to tie (mutually) recursive knots.
Low-Level functions
val create : ('a -> size:Base.int -> hash:Base.Hash.state -> Base.Hash.state) -> 'a tval observe : 'a t -> 'a -> size:Base.int -> hash:Base.Hash.state -> Base.Hash.state