Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 TraverseFilter.mapAccumulateFilter #4561
base: main
Are you sure you want to change the base?
Add TraverseFilter.mapAccumulateFilter #4561
Changes from 2 commits
021f5f8
17389c0
23fa3db
8040c23
cb6d411
277593b
15ec803
9adf4d5
a414be1
35706a7
778aad2
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we override this for some of the built in collections? State is rather slow so we should avoid it for List, Vector, Chain, NonEmptyList, NonEmptyVector, ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can copy
StaticMethods.mapAccumulateFromStrictFunctor
formapAccumulateFilter
, this will cover for some collectionsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like it does not check the default implementation (based on
State
), does it?Except maybe one for
Stream
, but I wouldn't count on it.For testing default implementations we usually use
ListWrapper
from testkit:ListWrapper.scala
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had straightforwardly copy-pasted and updated tests from
mapAccumulate
here:cats/tests/shared/src/test/scala/cats/tests/TraverseSuite.scala
Lines 45 to 56 in 70dbf8f
If that tests doesn't test default implementation too, I can update
mapAccumulateFilter
tests. Can you provide an example of how to passListWrapper
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am failing to understand how to use
ListWrapper
to testmapAccumulateFilter
. I was looking for examples in other Suites, but it is either suites for data and not typeclasses (OptionT
,Try
, etc.), or it refers to<Typeclass>Tests[ListWrapper].<methodToTest>
, like in theApplicativeSuite
:cats/tests/shared/src/test/scala/cats/tests/ApplicativeSuite.scala
Lines 102 to 104 in 70dbf8f
which I can not apply here, because we don't have
TraverseFilter[?].mapAccumulateFilter
. Am I missing something?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My apologies for the delay – I was snowed under a bit. Actually, there's
TraverseFilter
forListWrapper
:cats/testkit/src/main/scala/cats/tests/ListWrapper.scala
Lines 80 to 90 in 47fbad7
To test the default implementation you can either call it directly:
ListWrapper.traverseFilter.mapAccumulateFilter(...)
or make it an implicit in the scope:
And then you can work with
TraverseFilter
forListWrapper
as usual.