type +'a t = 'a Base_quickcheck.Generator.t
val create : (size:Base.Int.t -> random:Splittable_random.State.t -> 'a) -> 'a tval generate : 'a t -> size:Base.Int.t -> random:Splittable_random.State.t -> 'a
Generators form a monad. t1 >>= fun x -> t2 replaces each value x in t1 with the values in t2; each value's probability is the product of its probability in t1 and t2.
include Base.Monad.S with type 'a t := 'a t
module Monad_infix : sig ... endval return : 'a -> 'a treturn vreturns the (trivial) computation that returns v.
module Let_syntax : sig ... endval size : Base.Int.t tsize = create (fun ~size _ -> size)
val with_size : 'a t -> size:Base.Int.t -> 'a twith_size t ~size = create (fun ~size:_ random -> generate t ~size random)
val bool : Base.Bool.t tval char : Base.Char.t tval char_digit : Base.Char.t tval char_lowercase : Base.Char.t tval char_uppercase : Base.Char.t tval char_alpha : Base.Char.t tval char_alphanum : Base.Char.t tval char_print : Base.Char.t tval char_whitespace : Base.Char.t tval singleton : 'a -> 'a tval doubleton : 'a -> 'a -> 'a tval of_list : 'a Base.List.t -> 'a tProduce any of the given values, weighted equally.
of_list [ v1 ; ... ; vN ] = union [ singleton v1 ; ... ; singleton vN ]
val union : 'a t Base.List.t -> 'a tCombine arbitary generators, weighted equally.
union [ g1 ; ... ; gN ] = weighted_union [ (1.0, g1) ; ... ; (1.0, gN) ]
val of_sequence : p:Base.Float.t -> 'a Sequence.t -> 'a tGenerator for the values from a potentially infinite sequence. Chooses each value with probability
p, or continues with probability1-p. Must satisfy0. < p && p <= 1..
val tuple2 : 'a t -> 'b t -> ('a * 'b) tval tuple3 : 'a t -> 'b t -> 'c t -> ('a * 'b * 'c) tval tuple4 : 'a t -> 'b t -> 'c t -> 'd t -> ('a * 'b * 'c * 'd) tval tuple5 : 'a t -> 'b t -> 'c t -> 'd t -> 'e t -> ('a * 'b * 'c * 'd * 'e) tval tuple6 : 'a t -> 'b t -> 'c t -> 'd t -> 'e t -> 'f t -> ('a * 'b * 'c * 'd * 'e * 'f) tval variant2 : 'a t -> 'b t -> [ `A of 'a | `B of 'b ] tval variant3 : 'a t -> 'b t -> 'c t -> [ `A of 'a | `B of 'b | `C of 'c ] tval variant4 : 'a t -> 'b t -> 'c t -> 'd t -> [ `A of 'a | `B of 'b | `C of 'c | `D of 'd ] tval variant5 : 'a t -> 'b t -> 'c t -> 'd t -> 'e t -> [ `A of 'a | `B of 'b | `C of 'c | `D of 'd | `E of 'e ] tval variant6 : 'a t -> 'b t -> 'c t -> 'd t -> 'e t -> 'f t -> [ `A of 'a | `B of 'b | `C of 'c | `D of 'd | `E of 'e | `F of 'f ] tval geometric : p:Base.Float.t -> Base.Int.t -> Base.Int.t tgeometric ~p initproduces a geometric distribution (think "radioactive decay") that producesinitwith probabilityp, and otherwise recursively chooses fromgeometric ~p (init+1). Must satisfy0. < p && p <= 1..
val small_non_negative_int : Base.Int.t tsmall_non_negative_intproduces a non-negative int of a tractable size, e.g. allocating a value of this size should not run out of memory.
val small_positive_int : Base.Int.t tsmall_positive_intproduces a positive int of a tractable size, e.g. allocating a value of this size should not run out of memory.
val fn : 'a Base_quickcheck.Observer.t -> 'b t -> ('a -> 'b) tGenerators for functions; take observers for inputs and a generator for outputs.
val fn2 : 'a Base_quickcheck.Observer.t -> 'b Base_quickcheck.Observer.t -> 'c t -> ('a -> 'b -> 'c) tval fn3 : 'a Base_quickcheck.Observer.t -> 'b Base_quickcheck.Observer.t -> 'c Base_quickcheck.Observer.t -> 'd t -> ('a -> 'b -> 'c -> 'd) tval fn4 : 'a Base_quickcheck.Observer.t -> 'b Base_quickcheck.Observer.t -> 'c Base_quickcheck.Observer.t -> 'd Base_quickcheck.Observer.t -> 'e t -> ('a -> 'b -> 'c -> 'd -> 'e) tval fn5 : 'a Base_quickcheck.Observer.t -> 'b Base_quickcheck.Observer.t -> 'c Base_quickcheck.Observer.t -> 'd Base_quickcheck.Observer.t -> 'e Base_quickcheck.Observer.t -> 'f t -> ('a -> 'b -> 'c -> 'd -> 'e -> 'f) tval fn6 : 'a Base_quickcheck.Observer.t -> 'b Base_quickcheck.Observer.t -> 'c Base_quickcheck.Observer.t -> 'd Base_quickcheck.Observer.t -> 'e Base_quickcheck.Observer.t -> 'f Base_quickcheck.Observer.t -> 'g t -> ('a -> 'b -> 'c -> 'd -> 'e -> 'f -> 'g) tval compare_fn : 'a Base_quickcheck.Observer.t -> ('a -> 'a -> Base.Int.t) tGenerator for comparison functions; result is guaranteed to be a partial order.
val equal_fn : 'a Base_quickcheck.Observer.t -> ('a -> 'a -> Base.Bool.t) tGenerator for equality functions; result is guaranteed to be an equivalence relation.
val filter_map : 'a t -> f:('a -> 'b Base.Option.t) -> 'b tfilter_map t ~fproducesyfor everyxintsuch thatf x = Some y.
val filter : 'a t -> f:('a -> Base.Bool.t) -> 'a tfilter t ~fproduces everyxintsuch thatf x = true.
val recursive_union : 'a t Base.List.t -> f:('a t -> 'a t Base.List.t) -> 'a tGenerator for recursive data type with multiple clauses. At size 0, chooses only among the non-recursive cases; at sizes greater than 0, chooses among non-recursive and recursive cases, calling the recursive cases with decremented size.
type tree = Leaf | Node of tree * int * tree;; recursive_union [return Leaf] ~f:(fun self -> [let%map left = self and int = Int.gen and right = self in Node (left, int, right)])
val weighted_recursive_union : (Base.Float.t * 'a t) Base.List.t -> f:('a t -> (Base.Float.t * 'a t) Base.List.t) -> 'a tLike
recursive_union, with the addition of non-uniform weights for each clause.
val fixed_point : ('a t -> 'a t) -> 'a tFixed-point generator. Use
sizeto bound the size of the value and the depth of the recursion. There is no prescribed semantics forsizeexcept that it must be non-negative. For example, the following produces a naive generator for natural numbers:fixed_point (fun self -> match%bind size with | 0 -> singleton 0 | n -> with_size self ~size:(n-1) >>| Int.succ)
val weighted_union : (Base.Float.t * 'a t) Base.List.t -> 'a tweighted_union alistproduces a generator that combines the distributions of eachtinalistwith the associated weights, which must be finite positive floating point values.
val of_fun : (Base.Unit.t -> 'a t) -> 'a tof_fun fproduces a generator that lazily appliesf.It is recommended that
fnot be memoized. Instead, spread out the work of generating a whole distribution over manyof_funcalls combined withweighted_union. This allows lazily generated generators to be garbage collected after each test and the relevant portions cheaply recomputed in subsequent tests, rather than accumulating without bound over time.
val list : 'a t -> 'a Base.List.t tGenerators for lists, choosing each element independently from the given element generator.
listandlist_non_emptydistributesizeamong the list length and the sizes of each element.list_non_emptynever generates the empty list.list_with_lengthgenerates lists of the given length, and distributessizeamong the sizes of the elements.
val list_non_empty : 'a t -> 'a Base.List.t tval list_with_length : Base.Int.t -> 'a t -> 'a Base.List.t t