diff --git a/project/Boilerplate.scala b/project/Boilerplate.scala index 655f0610510..be8b3238642 100644 --- a/project/Boilerplate.scala +++ b/project/Boilerplate.scala @@ -284,11 +284,10 @@ object Boilerplate { def content(tv: TemplateVals) = { import tv._ - val tpes = synTypes.map { tpe => - s"F[$tpe]" - } - val fargs = (0 until arity).map("f" + _) - val fparams = fargs.zip(tpes).map { case (v, t) => s"$v:$t" }.mkString(", ") + val vals = (0 until arity).map("f" + _) + val tpes = synTypes.map(tpe => s"F[$tpe]") + val fargs = vals.mkString(", ") + val fparams = vals.zip(tpes).map { case (v, t) => s"$v:$t" }.mkString(", ") block""" |package cats @@ -302,7 +301,8 @@ object Boilerplate { | */ |trait FlatMapArityFunctions[F[_]] { self: FlatMap[F] => - /** @group FlatMapArity */ - - def flatMap$arity[${`A..N`}, Z]($fparams)(f: (${`A..N`}) => F[Z]): F[Z] = self.flatten(self.map$arity($fparams)(f)) + - def flatMap$arity[${`A..N`}, Z]($fparams)(f: (${`A..N`}) => F[Z]): F[Z] = + - flatten(map$arity($fargs)(f)) |} """ } @@ -352,12 +352,10 @@ object Boilerplate { def content(tv: TemplateVals) = { import tv._ - val tpes = synTypes.map { tpe => - s"M[$tpe]" - } - val fargs = (0 until arity).map("m" + _) - val fparams = fargs.zip(tpes).map { case (v, t) => s"$v:$t" }.mkString(", ") - val nestedExpansion = ParallelNestedExpansions(arity) + val vals = (0 until arity).map("m" + _) + val tpes = synTypes.map(tpe => s"M[$tpe]") + val fargs = vals.mkString(", ") + val fparams = vals.zip(tpes).map { case (v, t) => s"$v:$t" }.mkString(", ") block""" |package cats @@ -372,7 +370,7 @@ object Boilerplate { |abstract class ParallelArityFunctions2 extends ParallelArityFunctions { - /** @group ParTupleArity */ - def parTuple$arity[M[_], ${`A..N`}]($fparams)(implicit p: NonEmptyParallel[M]): M[(${`A..N`})] = - - p.flatMap.map(${nestedExpansion.products}) { case ${nestedExpansion.`(a..n)`} => (${`a..n`}) } + - parMap$arity($fargs)(Tuple$arity.apply) |} """ } @@ -605,9 +603,12 @@ object Boilerplate { | * | */ |trait FoldableNFunctions[F[_]] { self: Foldable[F] => + | private def slidingN[A, B](fa: F[A], n: Int)(f: Seq[A] => B) = + | toIterable(fa).iterator.sliding(n).withPartial(false).map(f).toList + | - /** @group FoldableSlidingN */ - def sliding$arity[A](fa: F[A]): List[$tupleTpe] = - - toIterable(fa).iterator.sliding($arity).withPartial(false).map(x => $tupleXN).toList + - slidingN(fa, $arity)(x => $tupleXN) |} """ }