gen.subsequence / shuffle / nonEmptyListOf / uniqueListOf #11

Closed
opened 2026-09-13 21:24:23 +09:00 by natsukium · 1 comment
Owner

Missing

Small list combinators every framework ships:

  • gen.subsequence xs — each element kept or dropped; shrinks toward dropping (Hedgehog Gen.subsequence).
  • gen.shuffle xs (Hedgehog Gen.shuffle, fast-check shuffledSubarray).
  • gen.nonEmptyListOf g.
  • gen.uniqueListOf lenRange g (fast-check uniqueArray); needs the filter/discard machinery or drop-duplicates.

Why

subsequence is the building block for gen.attrsWith (#4) and for "subset of declared property names" in jsonschema2nix. The others are a few lines each and keep callers from reimplementing them with bind.

Suggested shape

subsequence = xs: map (flags: filter by flags) (vectorOf (length xs) bool) — bool shrinks true -> false, so the list shrinks toward [ ].

## Missing Small list combinators every framework ships: - `gen.subsequence xs` — each element kept or dropped; shrinks toward dropping (Hedgehog `Gen.subsequence`). - `gen.shuffle xs` (Hedgehog `Gen.shuffle`, fast-check `shuffledSubarray`). - `gen.nonEmptyListOf g`. - `gen.uniqueListOf lenRange g` (fast-check `uniqueArray`); needs the filter/discard machinery or drop-duplicates. ## Why `subsequence` is the building block for `gen.attrsWith` (#4) and for "subset of declared property names" in jsonschema2nix. The others are a few lines each and keep callers from reimplementing them with `bind`. ## Suggested shape `subsequence = xs: map (flags: filter by flags) (vectorOf (length xs) bool)` — `bool` shrinks `true -> false`, so the list shrinks toward `[ ]`.
Author
Owner

Implemented in 60d0c55, pushed to main.

Implemented in 60d0c55, pushed to main.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
natsukium/nixcheck#11
No description provided.