'a t a generates values of type
'a with a specific probability
A monad is an abstraction of the concept of sequencing of computations. A value of type 'a monad represents a computation that returns a value of type 'a.
return v returns the (trivial) computation that returns v.
Produce any of the given values, weighted equally.
of_list [ v1 ; ... ; vN ] = union [ singleton v1 ; ... ; singleton vN ]
size produces a geometric distribution (think "radioactive decay") starting at 0
and increasing with probability 0.75. It produces natural numbers and is weighted
toward low values, making it a good default for, e.g., data structure sizes.
Generators for functions; take observers for inputs and a generator for outputs. The observer splits the space of possible inputs into a number of "buckets"; each randomly generated function applies the observer to an input, and produces a different output value for each bucket.
?branching_factor argument determines how many branches the function's
decision tree has, and thus how many categories of inputs it can distinguish. If
branching_factor defaults to a geometric distribution similar to
but capped by the maximum branching factor of the domain observers.
Generators for functions, annotated with sexps that describe the functions.
Intended for debugging purposes. These generators each produce a
whose description can be extracted using
filter_map t ~f produces
y for every
t such that
f x = Some y.
filter t ~f produces every
t such that
f x = true.
filter_map sparingly. Every time
f rejects a value, it
counts as a failed attempt to produce a value. Too many failures can cause
Quickcheck to take a long time to generate values, or fail a test if it fails more
times than the maximum configured number of attempts.
'a Choice.trepresents the choice of a value from a generator.
bind_choice t f is like
bind t f, except
f is passed an
'a Choice.t and can
thus use subsets of
t by using
Choice.gen with the
bind t f is equal to
bind_choice t (fun c -> f (Choice.value c)), although
bind is cheaper than
Empty generator that is guaranteed to fail to produce a value.
of_fun f produces a generator that lazily applies
f *MUST* be deterministic or else random value generation will fail. However, it
is recommended that
f not be memoized. Instead, spread out the work of generating
a whole distribution over many
of_fun calls combined with
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.
choose t ~random_float_between_zero_and_one makes a choice in
t at random, using
random_float_between_zero_and_one to produce random floats between 0. (inclusive)
and 1. (exclusive) for each weighted choice. If
t has been fully explored, it
`No_choices_remain. Otherwise it produces
`Choice c for some choice