elm-explorations / elm-explorations/test

Add `Fuzz.set` and `Fuzz.dict`

Open
#236 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Elm
Stars
244
Forks
40
Avg merge
1d 23h
Merged PRs (30d)
2

Description

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).

```elm
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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.