-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 traverseCollect
to TraverseFilter
typeclass
#4277
Changes from 5 commits
4f8b7e4
4590a07
c626183
f73a186
a226d01
25e8bbe
9455986
2e250c5
6afcfaf
b2d2d67
d1fa2f4
cdc49db
fd87685
0cd6d46
cf96c2b
8b7dcb6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -27,6 +27,9 @@ trait TraverseFilterSyntax extends TraverseFilter.ToTraverseFilterOps | |||
private[syntax] trait TraverseFilterSyntaxBinCompat0 { | ||||
implicit def toSequenceFilterOps[F[_], G[_], A](fgoa: F[G[Option[A]]]): SequenceFilterOps[F, G, A] = | ||||
new SequenceFilterOps(fgoa) | ||||
|
||||
implicit def toTraverseCollectOps[F[_], G[_], A](fa: F[A]): TraverseCollectOps[F, G, A] = | ||||
new TraverseCollectOps(fa) | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this just be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I followed current implementations like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah the situation for
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you know where I could find examples to follow? I am not sure what I need to change here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, check out any of the syntax implementations :) I'm just proposing that we rename There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I understand your point now. I thought it was a remark about implementation details. Thanks for your work on this PR ! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, sorry I wasn't so clear on that. Great, thank you too! |
||||
} | ||||
|
||||
final class SequenceFilterOps[F[_], G[_], A](private val fgoa: F[G[Option[A]]]) extends AnyVal { | ||||
|
@@ -41,3 +44,12 @@ final class SequenceFilterOps[F[_], G[_], A](private val fgoa: F[G[Option[A]]]) | |||
*/ | ||||
def sequenceFilter(implicit F: TraverseFilter[F], G: Applicative[G]): G[F[A]] = F.sequenceFilter(fgoa) | ||||
} | ||||
|
||||
final class TraverseCollectOps[F[_], G[_], A](private val fa: F[A]) extends AnyVal { | ||||
|
||||
def traverseCollect[B](f: PartialFunction[A, G[B]])(implicit | ||||
F: TraverseFilter[F], | ||||
G: Applicative[G] | ||||
): G[F[B]] = | ||||
F.traverseCollect(fa)(f) | ||||
} |
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 write this without the ops import? Current practice is try to avoid circular dependencies between syntax and typeclasses.
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 tried to do manual
sequence
for this operation. WDYT?