Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Test

Per-type value generators for property testing.

A generator is the unwrapped Quickcheck.Gen: a size-bounded draw from the ambient Random capability. That makes a run deterministic under a seed (the Quickcheck runner serves Random from a seeded SplitMix64 stream), and lets a derived instance recurse through its fields’ arbitrary while composing cleanly with the Gen combinators. The primitive instances delegate to Quickcheck’s canonical generators, so a derived type draws from the same distributions the hand-written harness does.

Wrap an instance back into a Gen with arb_gen to feed it to quickcheck.

Type Classes

Arbitrary

class Arbitrary(a)
  arbitrary : (Int) -> a ! {Random | e}

A structural generator, sized by a fuel budget. deriving (Arbitrary) spends the budget on depth: at each recursive constructor it draws its fields a size smaller, and once the budget runs out it restricts to non-recursive constructors, so generation always terminates.

Instances

arbitraryInt

instance arbitraryInt : Arbitrary(Int)

arbitraryI64

instance arbitraryI64 : Arbitrary(I64)

arbitraryU64

instance arbitraryU64 : Arbitrary(U64)

arbitraryBool

instance arbitraryBool : Arbitrary(Bool)

arbitraryUnit

instance arbitraryUnit : Arbitrary(Unit)

arbitraryChar

instance arbitraryChar : Arbitrary(Char)

arbitraryFloat

instance arbitraryFloat : Arbitrary(Float)

arbitraryString

instance arbitraryString : Arbitrary(String)

arbitraryOption

instance arbitraryOption : Arbitrary(Option(a))

arbitraryList

instance arbitraryList : Arbitrary(List(a))

Functions and Values

arb_gen

arb_gen : forall a. () -> Quickcheck.Gen(a)

The generator of an Arbitrary type, as a Quickcheck.Gen ready for quickcheck/gen_at.