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

Cogen.cogenMap should not require ordering on the values #356

Closed
joroKr21 opened this issue Sep 21, 2017 · 0 comments
Closed

Cogen.cogenMap should not require ordering on the values #356

joroKr21 opened this issue Sep 21, 2017 · 0 comments

Comments

@joroKr21
Copy link
Member

Keys in a Map are always distinct. Therefore sorting by the keys should be sufficient:

implicit def cogenMap[K: Cogen: Ordering, V: Cogen]: Cogen[Map[K, V]] =
  Cogen.it(_.toVector.sortBy(_._1).iterator)
joroKr21 added a commit to joroKr21/scalacheck that referenced this issue Sep 21, 2017
It's safe to sort only by the keys, because they are distinct.

Fixes typelevel#356
joroKr21 added a commit to joroKr21/scalacheck that referenced this issue Sep 23, 2017
It's safe to sort only by the keys, because they are distinct.

Fixes typelevel#356
@non non closed this as completed in #357 Oct 4, 2017
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