Skip to content

Commit 37f75b3

Browse files
committed
mima hacks
1 parent f6dcbd4 commit 37f75b3

3 files changed

Lines changed: 56 additions & 4 deletions

File tree

core/src/main/scala/cats/syntax/apply.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
package cats
2323
package syntax
2424

25-
trait ApplySyntax extends TupleSemigroupalSyntax with FunctionApplySyntax {
25+
trait ApplySyntax extends TupleSemigroupalSyntax with FunctionApplySyntax with FunctionApplySyntax2 {
2626
@deprecated("Kept for binary compatibility", "2.10.0")
2727
final def catsSyntaxApply[F[_], A](fa: F[A], F: Apply[F]): Apply.Ops[F, A] =
2828
new Apply.Ops[F, A] {

project/Boilerplate.scala

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ object Boilerplate {
3333
GenParallelArityFunctions2,
3434
GenFoldableArityFunctions,
3535
GenFunctionSyntax,
36+
GenFunctionSyntax2,
3637
GenTupleParallelSyntax,
3738
GenTupleShowInstances,
3839
GenTupleMonadInstances,
@@ -624,9 +625,6 @@ object Boilerplate {
624625
|package cats
625626
|package syntax
626627
|
627-
|import cats.Functor
628-
|import cats.Semigroupal
629-
|
630628
|trait FunctionApplySyntax {
631629
| implicit def catsSyntaxFunction1Apply[T, A0](f: Function1[A0, T]): Function1ApplyOps[T, A0] = new Function1ApplyOps(f)
632630
- implicit def catsSyntaxFunction${arity}Apply[T, ${`A..N`}](f: $function): Function${arity}ApplyOps[T, ${`A..N`}] = new Function${arity}ApplyOps(f)
@@ -639,6 +637,36 @@ object Boilerplate {
639637
|
640638
-private[syntax] final class Function${arity}ApplyOps[T, ${`A..N`}](private val f: $function) extends AnyVal with Serializable {
641639
- def liftN[F[_]: Functor: Semigroupal]($typedParams): F[T] = Semigroupal.map$arity(${`a..n`})(f)
640+
- private[syntax] def parLiftN[F[_]: Parallel]($typedParams): F[T] = Parallel.parMap$arity(${`a..n`})(f)
641+
-}
642+
"""
643+
}
644+
}
645+
646+
object GenFunctionSyntax2 extends Template {
647+
def filename(root: File) = root / "cats" / "syntax" / "FunctionApplySyntax2.scala"
648+
649+
override def range = 2 to maxArity
650+
651+
def content(tv: TemplateVals) = {
652+
import tv._
653+
654+
val function = s"Function$arity[${`A..N`}, T]"
655+
656+
val typedParams = synVals.zip(synTypes).map { case (v, t) => s"$v: F[$t]" }.mkString(", ")
657+
658+
// arity 1 left out intentionally, for it's part of GenFunctionSyntax already.
659+
// SyntaxSuite ensures that it exists.
660+
661+
block"""
662+
|package cats
663+
|package syntax
664+
|
665+
|trait FunctionApplySyntax2 {
666+
- implicit def catsSyntaxFunction${arity}Apply2[T, ${`A..N`}](f: $function): Function${arity}ApplyOps2[T, ${`A..N`}] = new Function${arity}ApplyOps2(f)
667+
|}
668+
|
669+
-private[syntax] final class Function${arity}ApplyOps2[T, ${`A..N`}](private val f: $function) extends AnyVal with Serializable {
642670
- def parLiftN[F[_]: NonEmptyParallel]($typedParams): F[T] = Parallel.parMap$arity(${`a..n`})(f)
643671
-}
644672
"""

tests/shared/src/test/scala/cats/tests/SyntaxSuite.scala

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,30 @@ object SyntaxSuite {
345345
result3: F[T]
346346
}
347347

348+
def testParLiftNNonEmpty[F[_]: NonEmptyParallel: Functor, A, B, C, T] = {
349+
val fa = mock[F[A]]
350+
val fb = mock[F[B]]
351+
val fc = mock[F[C]]
352+
353+
val fapply1 = mock[A => T]
354+
355+
val result1 = fapply1.parLiftN(fa)
356+
357+
result1: F[T]
358+
359+
val fapply2 = mock[(A, B) => T]
360+
361+
val result2 = fapply2.parLiftN(fa, fb)
362+
363+
result2: F[T]
364+
365+
val fapply3 = mock[(A, B, C) => T]
366+
367+
val result3 = fapply3.parLiftN(fa, fb, fc)
368+
369+
result3: F[T]
370+
}
371+
348372
def testParallelBi[M[_], F[_], T[_, _]: Bitraverse, A, B, C, D](implicit P: Parallel.Aux[M, F]): Unit = {
349373
val tab = mock[T[A, B]]
350374
val f = mock[A => M[C]]

0 commit comments

Comments
 (0)