-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Remove redundant Monad constraints from Parallel syntax #3856
Conversation
implicit final def catsSyntaxParallelSequence[T[_]: Traverse, M[_]: Monad, A]( | ||
tma: T[M[A]] | ||
): ParallelSequenceOps[T, M, A] = new ParallelSequenceOps[T, M, A](tma) | ||
@deprecated("Kept for binary compatibility", "2.5.1") |
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.
Not sure if this should be 2.5.1 or 2.6.0
Since this is not working, the other option is to create new |
Would something along this line be binary compatible? final class ParallelTraversableOps[T[_], A](private val ta: T[A]) extends AnyVal {
def parTraverse[M[_]: Monad, B](f: A => M[B])(implicit T: Traverse[T], P: Parallel[M]): M[T[B]] =
Parallel.parTraverse(ta)(f)
}
final class ParallelTraversableOps2[T[_], A](private val ta: T[A]) extends AnyVal {
def parTraverse[M[_], B](f: A => M[B])(implicit T: Traverse[T], P: Parallel[M]): M[T[B]] =
Parallel.parTraverse(ta)(f)
} |
Yes, that's what I meant. Unfortunately adding an overload in Scala 2.12 changes the name mangling of extension methods. |
@@ -108,9 +123,11 @@ trait ParallelFoldMapASyntax { | |||
} | |||
|
|||
final class ParallelTraversableOps[T[_], A](private val ta: T[A]) extends AnyVal { | |||
def parTraverse[M[_]: Monad, B](f: A => M[B])(implicit T: Traverse[T], P: Parallel[M]): M[T[B]] = | |||
@deprecated("Kept for binary compatibility", "2.5.1") | |||
def parTraverse[M[_], B](f: A => M[B], M: Monad[M], T: Traverse[T], P: Parallel[M]): M[T[B]] = |
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.
shouldn't this have a second third parameter list instead?
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.
WDYM? 🤔
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.
You moved the monad constraint in the first position of the implicit parameter list. My understanding of context bounds is that a new parameter list is appended to the method definition in this way:
def parTraverse[M[_]: Monad, B](f: A => M[B])(implicit T: Traverse[T], P: Parallel[M]): M[T[B]] =
// is equivalent to
def parTraverse[M[_], B](f: A => M[B])(implicit T: Traverse[T], P: Parallel[M])(implicit M: Monad[M]): M[T[B]] =
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.
Nope, in Scala 2 you can have only one implicit list and the context bounds come first.
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.
Didn't know that, thanks for the explanation.
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.
But in the bytecode there is only one parameter list anyway (and no implicits) which is why both are binary compatible:
def parTraverse[M[_]: Monad, B](f: A => M[B])(implicit T: Traverse[T], P: Parallel[M]): M[T[B]]
def parTraverse[M[_], B](f: A => M[B], M: Monad[M], T: Traverse[T], P: Parallel[M]): M[T[B]]
That's a neat trick for library authors 😄
ee88b18
to
afc4d57
Compare
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.
LGTM, but I think this warrants a bump to 2.6.0
afc4d57
to
b56a028
Compare
Binary compatible version of #2180
Fixes #2254