metamon/generator/shrink
Generic shrink helpers used by metamon/generator to build
Tree(a)-shaped values for primitive types. Each helper returns a
list of “smaller” candidates that the runner will explore in order.
Values
pub fn int_toward(origin: Int, value: Int) -> List(Int)
Halve value toward origin. Returns the empty list when no
further progress is possible (e.g. value already equals origin).
The classic QuickCheck-style shrink: try the origin first, then
progressively closer-to-value candidates. For example,
int_toward(0, 64) yields [0, 32, 48, 56, 60, 62, 63]. The
runner walks this list in order, so the smallest counter-example
is found in a single step when origin itself triggers the bug.
pub fn list_drops(items: List(a)) -> List(List(a))
Shrink a list by trying progressively smaller drops: drop everything, then drop half, then drop a quarter, etc.
Returns candidate sub-lists in order from “most aggressive” to “least aggressive” so the runner finds short failing examples first.