Basic Shrinkers
val atomic : _ t
This shrinker treats a type as atomic, never attempting to produce smaller values.
val unit : 'a t
val bool : 'a t
val char : 'a t
val string : 'a t
val int : 'a t
val int32 : 'a t
val int63 : 'a t
val int64 : 'a t
val nativeint : 'a t
val float : 'a t
val sexp : 'a t
val option : 'a t -> 'a t
val list : 'a t -> 'a t
val both : 'a t -> 'a t -> 'a t
val either : 'a t -> 'a t -> 'a t
val result : 'a t -> 'a t -> 'a t
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_using_comparator : comparator:('key, 'cmp) Base.Comparator.t -> 'key t -> 'data t -> ('key, 'data, 'cmp) Base.Map.Using_comparator.Tree.t t
val 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 t
val filter : 'a t -> f:('a -> Base.bool) -> 'a t
val filter_map : 'a t -> f:('a -> 'b Base.option) -> f_inverse:('b -> 'a) -> 'b t
Filters and maps according to
f
, and provides input tot
viaf_inverse
. Only thef
direction produces options, intentionally.
Shrinkers for Recursive Types
val fixed_point : ('a t -> 'a t) -> 'a t
Ties 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 t
Creates a
t
that 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 t
val shrink : 'a t -> 'a -> 'a Base.Sequence.t