typelevel / typelevel/scalacheck

Generating a list of size N where each element is distinct.

Open
#352 7 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Scala
Stars
2k
Forks
393
Avg merge
6h 42m
Merged PRs (30d)
4

Description

I'm proposing something like:

def sizedDistinctListOf[T](size: Int, gen: Gen[T], eq: (T, T) => Boolean): Gen[List[T]]

In my own codebase, I've got something similar where T is constrained by the Eq typeclass from Cats. This allows me to define what distinctiveness means. From my understanding, ScalaCheck has no dependency on Cats.

For instance, you may have a case class Person(name: String, age: Int) and for a specific scenario, you might want to generate List[Person] where each element contains a different name and age pair, whereas for some other cases, you might want to generate List[Person] where each element has a different age.

Happy to submit a PR if people find this useful.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing ScalaCheck's existing Gen and List-generation APIs, then compare the proposed sizedDistinctListOf signature with current generator conventions. Done means a generator can produce lists of the requested size while enforcing distinctness through the supplied equality function, with tests covering different notions of distinctness.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
testing-qa
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.