qcheck/random
Random
The random module provides basic random value generators that can be used to define Generators.
They are mostly inteded for internal use or “advanced” manual construction of generators. In typical usage, you will probably not need to interact with these functions much, if at all. As such, they are currently mostly undocumented.
Types
Constants
pub const max_int: Int
Attempting to generate values below this limit will not lead to good random results.
Functions
pub fn float_weighted(
first: #(Float, a),
others: List(#(Float, a)),
) -> Generator(a)
Like weighted
but uses Floats
to specify the weights.
Generally you should prefer weighted
as it is faster.
pub fn random_sample(generator: Generator(a)) -> a
pub fn random_seed() -> Seed
random_seed()
creates a new randomly-generated seed. You can use it when
you don’t care about having specifically reproducible results.
Example
Use a random seed for the Config
.
let config =
qcheck.default_config()
|> qcheck.with_seed(qcheck.random_seed())
pub fn seed(n: Int) -> Seed
seed(n) creates a new seed from the given integer,
n`.
Example
Use a specific seed for the Config
.
let config =
qcheck.default_config()
|> qcheck.with_seed(qcheck.seed(124))
pub fn then(
generator: Generator(a),
f: fn(a) -> Generator(b),
) -> Generator(b)
then
is an alias for bind
.
pub fn to_random_yielder(generator: Generator(a)) -> Yielder(a)
pub fn to_yielder(
generator: Generator(a),
seed: Seed,
) -> Yielder(a)