FR
importPour l'utiliser : import Data.Gen

Data.Gen — friendly combinators for authoring generators

Synopsis
constant : Int -> Int -> Range

constant lo hi: uniform over [lo, hi], shrinking toward lo.

constantFrom : Int -> Int -> Int -> Range

constantFrom origin lo hi: uniform over [lo, hi], shrinking toward origin.

int : Range -> Gen Int

A uniform integer in the range, shrinking toward its origin.

nat : Range -> Gen Nat

A uniform Nat in the range (a negative bound is clamped to 0). The companion of int for indices and other naturals.

natRange : Nat -> Nat -> Gen Nat

A uniform Nat in [lo, hi] (inclusive), with NAT bounds — no toInt. An inverted range (lo > hi) is treated as [lo, lo].

natBelow : Nat -> Gen Nat

A uniform Nat strictly below n, i.e. in [0, n) — the natural way to pick a valid index into a length-n structure. natBelow 0 yields 0 (there is no value below 0); callers guard the empty case.

bool : Gen Bool

A boolean; True shrinks to False.

char : Int -> Int -> Gen Char

A character in [lo, hi] (by code point), shrinking toward lo.

oneOf : List (Gen a) -> Gen a

Pick one generator uniformly (the list must be non-empty).

element : List a -> Gen a

element xs generates one of the given VALUES uniformly.

listOf : Range -> Gen a -> Gen (List a)

A list whose length is drawn from lenRange, each element from g.

sample : Gen a -> List a

A spread of sample values (run at a fixed size across a few seeds), so a student can SEE what a generator produces (oppi gen sample).