cardano-foundation / cardano-wallet

HTTP server & command-line for managing UTxOs and HD wallets in Cardano.
Apache License 2.0
757 stars 213 forks source link

[ADP-3272] Add generator functions `genNonEmptyDisjoint{Set,Map}`. #4580

Closed jonathanknowles closed 2 months ago

jonathanknowles commented 2 months ago

This PR adds the following generators to Test.QuickCheck.Extra:

genNonEmptyDisjointSet :: Ord a =>          Gen a -> Set   a -> Gen (Set   a)
genNonEmptyDisjointMap :: Ord k => Gen k -> Gen v -> Map k v -> Gen (Map k v)

These functions are useful in situations where you have a pre-existing Set (or Map), and you want to generate another Set (or Map) that is guaranteed to be non-empty and disjoint to the original.

Issue

ADP-3272

jonathanknowles commented 2 months ago

💎 why not to produce PR in quickcheck?

I suspect the bar for getting things into QuickCheck is rather high! We'd have to demonstrate that the functions are general enough to have widespread appeal.

And even if we succeed, then we'd have to wait for several months for a new version.

Having said that, I do think that some of the functions in this module could be up-streamed, or separated out into their own library.

jonathanknowles commented 2 months ago

Merging manually, since: