typelevel / typelevel/cats

FoldableTests are not testing sequence_/traverse_

Open
#2,679 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Scala
Stars
5.5k
Forks
1.2k
Avg merge
2d 10h
Merged PRs (30d)
5

Description

see: https://github.com/typelevel/cats-collections/pull/152/commits/4812b86470b6b5255b6e145b40861d2c01565f30#diff-1f70710e148c78ab48fdd3687d6ecd0bR201

I had to add that to get full test coverage.

We could have a law that: fa.sequence_ == fa.foldMap(identity) where we construct the natural Monoid[G[Unit]] for an Applicative.

More generally, I think we should have a practice that each instance matches an instance with only the abstract methods proxied through. This guarantees that all the other methods are only override for efficiency, not to change any semantics. If we made sure to test this way we could simplify our tests since we only need to write laws on the abstract methods, and then the additional law that we match the proxied instance.

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 with FoldableTests and the referenced pull request commit to see how sequence_ and traverse_ are currently exercised. Determine which laws should cover those methods, including the proposed sequence_ == foldMap(identity) relationship, then run the relevant Foldable law tests; done means the missing behavior is covered without changing semantics.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.