'a Choice.t
represents the choice of a value from a generator. It also
encapsulates the history of which random decisions were made to reach that value,
including all choices along the way that failed to produce a value.
updated_gen t ~keep
produces a generator representing a subset of the
probability distribution from which t
was constructed.
The subset determined by keep
refers to notions of "left" and "right" with
respect to choices in a gen
. For this purpose, a generator can be thought of as
a potentially infinite sequence of weighted choices, and operations on generators
preserve the order of this sequence. The keep
argument determines where to
"cut" this sequence relative to the current choice. This property can be used to
construct generators that do not repeat choices, or do not repeat the same set of
choices in a different order, which is useful, e.g., for constructing lists of
unique values or unique sets of values.
In all variants of keep
, any failed choices that were made in constructing t
are discarded.
Do not assume that a generator has any particular order: for example, do not count
on an int
generator being in strictly ascending order.
value t
produces the value chosen from original_gen t
.
attempts_used t
reports the number of attempts made to choose a value. It is
always at least 1, since there must have been one successful attempt; it may be
higher to indicate failed attempts.