Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Fuzz.set and Fuzz.dict #236

Open
jfmengels opened this issue Jan 12, 2025 · 0 comments
Open

Add Fuzz.set and Fuzz.dict #236

jfmengels opened this issue Jan 12, 2025 · 0 comments

Comments

@jfmengels
Copy link

The Fuzz module has Fuzz.list and Fuzz.array, but doesn't have Fuzz.set nor Fuzz.dict.

Currently, these are relatively easy to create in user code, but having to do this every time we need such a fuzzer is tedious.

I haven't tried them out but I believe these implementations would work (or be good starting positions if they don't).

set : Fuzz comparable -> Fuzz (Set comparable)
set fuzzer =
  list fuzzer
    |> map Set.fromList

dict : Fuzz comparable -> Fuzz a -> Fuzz (Dict comparable a)
dict keyFuzzer valueFuzzer =
  list (Tuple.pair keyFuzzer valueFuzzer)
    |> map Dict.fromList

There is a risk of generating the same keys multiple times which is wasteful, and maybe there are better implementations. In the meantime, I think this would be a valuable addition to the package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant