Arbitrary Typeclass #
The Arbitrary typeclass represents types for which there exists a
random generator suitable for property-based testing, similar to
Haskell QuickCheck's Arbitrary typeclass and Rocq/Coq QuickChick's Gen typeclass.
(Note: the SampleableExt involves types which have both a generator & a shrinker,
and possibly a non trivial proxy type,
whereas Arbitrary describes types which have a generator only.)
Main definitions #
Arbitrarytypeclass
References #
The Arbitrary typeclass represents types for which there exists a
random generator suitable for property-based testing.
- This is the equivalent of Haskell QuickCheck's
Arbitrarytypeclass. - In QuickChick, this typeclass is called
Gen, butGenis already a reserved keyword in Plausible, so we call this typeclassArbitraryfollowing the Haskell QuickCheck convention).
- arbitrary : Gen α
A random generator for values of the given type.
Instances
Samples from the generator associated with the Arbitrary instance for a type,
using size as the size parameter for the generator.
To invoke this function, you will need to specify what type α is,
for example by doing runArbitrary (α := Nat) 10.
Equations
Instances For
Equations
Equations
This can be specialized into customized Arbitrary Char instances.
The resulting instance has 1 / p chances of making an unrestricted choice of characters
and it otherwise chooses a character from chars with uniform probability.