data Susp a = Susp (Lazy a)
import nécessaire.Gen — pure generators with integrated (Hedgehog-style) shrinking
Synopsis
data Susp a = Susp (Lazy a)demand : Susp a -> adata ShrinkTree a = ShrinkNode a (Lazy (List (Susp (ShrinkTree a))))treeValue : ShrinkTree a -> akidsOf : ShrinkTree a -> List (Susp (ShrinkTree a))unfoldShrinkTree : (a -> List a) -> a -> ShrinkTree asuspendForest : (a -> List a) -> List a -> List (Susp (ShrinkTree a))mapShrinkTree : (a -> b) -> ShrinkTree a -> ShrinkTree bmapForest : (a -> b) -> List (Susp (ShrinkTree a)) -> List (Susp (ShrinkTree b))bindShrinkTree : ShrinkTree a -> (a -> ShrinkTree b) -> ShrinkTree brebind : List (Susp (ShrinkTree a)) -> (a -> ShrinkTree b) -> List (Susp (ShrinkTree b))data Gen a = MkGen (Int -> Int -> ShrinkTree a)runGen : Int -> Int -> Gen a -> ShrinkTree agenValue : Int -> Int -> Gen a -> asplitSeed : Int -> (Int, Int)mapGen : (a -> b) -> Gen a -> Gen bpureGen : a -> Gen aapGen : Gen (a -> b) -> Gen a -> Gen bbindGen : Gen a -> (a -> Gen b) -> Gen bdata Range = MkRange Int Int Int -- origin lo hihalves : Int -> List Inttowards : Int -> Int -> List IntgenIntRange : Range -> Gen IntgenBool : Gen BoolshrinkCounterexample : (a -> Bool) -> ShrinkTree a -> afirstFailingChild : (a -> Bool) -> List (Susp (ShrinkTree a)) -> Maybe (ShrinkTree a)
demand : Susp a -> a
data ShrinkTree a = ShrinkNode a (Lazy (List (Susp (ShrinkTree a))))
A rose tree of shrinks: a value and a forest of (suspended) smaller candidates. The forest is lazy, so constructing a node costs nothing for its children — they are built only when shrinking actually explores them. A passing trial never forces it.
treeValue : ShrinkTree a -> a
kidsOf : ShrinkTree a -> List (Susp (ShrinkTree a))
unfoldShrinkTree : (a -> List a) -> a -> ShrinkTree a
Build a tree by repeatedly applying a shrink function (children suspended).
suspendForest : (a -> List a) -> List a -> List (Susp (ShrinkTree a))
mapShrinkTree : (a -> b) -> ShrinkTree a -> ShrinkTree b
mapForest : (a -> b) -> List (Susp (ShrinkTree a)) -> List (Susp (ShrinkTree b))
bindShrinkTree : ShrinkTree a -> (a -> ShrinkTree b) -> ShrinkTree b
Monadic tree bind (the integrated-shrinking heart): shrink the outer value (re-running k on each outer shrink) and then the inner value.
rebind : List (Susp (ShrinkTree a)) -> (a -> ShrinkTree b) -> List (Susp (ShrinkTree b))
data Gen a = MkGen (Int -> Int -> ShrinkTree a)
Gen a = Size -> Seed -> ShrinkTree a. Size and Seed are Int; the seed is oppi's splitmix (Random).
runGen : Int -> Int -> Gen a -> ShrinkTree a
genValue : Int -> Int -> Gen a -> a
Generate just the value (drop the shrink tree).
splitSeed : Int -> (Int, Int)
mapGen : (a -> b) -> Gen a -> Gen b
pureGen : a -> Gen a
apGen : Gen (a -> b) -> Gen a -> Gen b
bindGen : Gen a -> (a -> Gen b) -> Gen b
data Range = MkRange Int Int Int -- origin lo hi
A Range fixes the bounds AND the origin — the value that shrinking moves toward. constant lo hi (see Data.Gen) is uniform with origin lo.
halves : Int -> List Int
towards : Int -> Int -> List Int
Integer shrinks of x toward origin: the origin first, then closing in on x by binary search. Works in both directions (so it terminates for x below origin too). towards 0 100 = [0, 50, 75, 88, 94, 97, 99]; towards 0 (negate 100) = [0, -50, -75, -88, -94, -97, -99].
genIntRange : Range -> Gen Int
The engine behind Data.Gen.int and the Arbitrary instances: a uniform integer in the range, shrinking toward its origin.
genBool : Gen Bool
A boolean; True shrinks to False (the minimal case).
shrinkCounterexample : (a -> Bool) -> ShrinkTree a -> a
Given a failing value's tree and the property, walk to a minimal failing value: greedily descend into the first failing child until none fails. This is what the runner does when a property is falsified. prop is the property HOLDING; the returned value is the smallest one where it FAILS.
firstFailingChild : (a -> Bool) -> List (Susp (ShrinkTree a)) -> Maybe (ShrinkTree a)