Module Base_quickcheck__.Observer
type -'a t
= 'a Base_quickcheck__.Observer0.t
Basic Observers
val opaque : _ t
Produces 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 unit : Base.unit t
val bool : Base.bool t
val char : Base.char t
val string : Base.string t
val int : Base.int t
val int32 : Base.int32 t
val int63 : Base.Int63.t t
val int64 : Base.int64 t
val nativeint : Base.nativeint t
val float : Base.float t
val sexp : Base.Sexp.t t
val option : 'a t -> 'a Base.option t
val list : 'a t -> 'a Base.list t
val both : 'a t -> 'b t -> ('a * 'b) t
val either : 'a t -> 'b t -> ('a, 'b) Base.Either.t t
val result : 'a t -> 'b t -> ('a, 'b) Base.Result.t t
val bigstring : (Base.char, Stdlib.Bigarray.int8_unsigned_elt, Stdlib.Bigarray.c_layout) Stdlib.Bigarray.Array1.t t
val float32_vec : (Base.float, Stdlib.Bigarray.float32_elt, Stdlib.Bigarray.fortran_layout) Stdlib.Bigarray.Array1.t t
val float64_vec : (Base.float, Stdlib.Bigarray.float64_elt, Stdlib.Bigarray.fortran_layout) Stdlib.Bigarray.Array1.t t
val float32_mat : (Base.float, Stdlib.Bigarray.float32_elt, Stdlib.Bigarray.fortran_layout) Stdlib.Bigarray.Array2.t t
val float64_mat : (Base.float, Stdlib.Bigarray.float64_elt, Stdlib.Bigarray.fortran_layout) Stdlib.Bigarray.Array2.t t
val fn : 'a Base_quickcheck.Generator.t -> 'b t -> ('a -> 'b) t
Produces 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 t
val set_t : 'elt t -> ('elt, 'cmp) Base.Set.t t
val map_tree : 'key t -> 'data t -> ('key, 'data, 'cmp) Base.Map.Using_comparator.Tree.t t
val set_tree : 'elt t -> ('elt, 'cmp) Base.Set.Using_comparator.Tree.t t
Observers Based on Hash Functions
val of_hash_fold : (Base.Hash.state -> 'a -> Base.Hash.state) -> 'a t
Creates 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
val fixed_point : ('a t -> 'a t) -> 'a t
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 t
Creates a
t
that forces the lazy argument as necessary. Can be used to tie (mutually) recursive knots.
Low-Level functions
Most users do not need to call these functions.
val create : ('a -> size:Base.int -> hash:Base.Hash.state -> Base.Hash.state) -> 'a t
val observe : 'a t -> 'a -> size:Base.int -> hash:Base.Hash.state -> Base.Hash.state