Basic Shrinkers
val atomic : _ tThis shrinker treats a type as atomic, never attempting to produce smaller values.
val unit : 'a tval bool : 'a tval char : 'a tval string : 'a tval int : 'a tval int32 : 'a tval int63 : 'a tval int64 : 'a tval nativeint : 'a tval float : 'a tval sexp : 'a tval option : 'a t -> 'a tval list : 'a t -> 'a tval both : 'a t -> 'a t -> 'a tval either : 'a t -> 'a t -> 'a tval result : 'a t -> 'a t -> 'a t
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_using_comparator : comparator:('key, 'cmp) Base.Comparator.t -> 'key t -> 'data t -> ('key, 'data, 'cmp) Base.Map.Using_comparator.Tree.t tval set_tree_using_comparator : comparator:('elt, 'cmp) Base.Comparator.t -> 'elt t -> ('elt, 'cmp) Base.Set.Using_comparator.Tree.t t
Modifying Shrinkers
val map : 'a t -> f:('a -> 'b) -> f_inverse:('b -> 'a) -> 'b tval filter : 'a t -> f:('a -> Base.bool) -> 'a tval filter_map : 'a t -> f:('a -> 'b Base.option) -> f_inverse:('b -> 'a) -> 'b tFilters and maps according to
f, and provides input totviaf_inverse. Only thefdirection produces options, intentionally.
Shrinkers for Recursive Types
val fixed_point : ('a t -> 'a t) -> 'a tTies the recursive knot to shrink recursive types.
For example, here is an shrinker for binary trees:
let tree_shrinker leaf_shrinker = fixed_point (fun self -> either leaf_shrinker (both self self) |> map ~f:(function | First leaf -> `Leaf leaf | Second (l, r) -> `Node (l, r)) ~f_inverse:(function | `Leaf leaf -> First leaf | `Node (l, r) -> Second (l, r)))
val of_lazy : 'a t Base.Lazy.t -> 'a tCreates a
tthat forces the lazy argument as necessary. Can be used to tie (mutually) recursive knots.
Low-level functions
val create : ('a -> 'a Base.Sequence.t) -> 'a tval shrink : 'a t -> 'a -> 'a Base.Sequence.t