Skip to content

Commit 224ccb1

Browse files
authored
Issue 3293: Generate Show instances for Tuple3 and higher (typelevel#3299)
1 parent c0a77ee commit 224ccb1

21 files changed

+698
-226
lines changed

bench/src/main/scala/cats/bench/ParTraverseBench.scala

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package cats.bench
33
import cats.{Bitraverse, Parallel, Traverse}
44
import cats.instances.int._
55
import cats.instances.either._
6-
import cats.instances.tuple._
76
import cats.instances.vector._
87
import org.openjdk.jmh.annotations.{Benchmark, Scope, State}
98

core/src/main/scala/cats/Bifoldable.scala

+4-2
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,11 @@ import scala.annotation.implicitNotFound
4040
}
4141
}
4242

43-
object Bifoldable {
43+
object Bifoldable extends cats.instances.NTupleBitraverseInstances {
4444
implicit def catsBitraverseForEither: Bitraverse[Either] = cats.instances.either.catsStdBitraverseForEither
45-
implicit def catsBitraverseForTuple2: Bitraverse[Tuple2] = cats.instances.tuple.catsStdBitraverseForTuple2
45+
46+
@deprecated("Use catsStdBitraverseForTuple2 in cats.instances.NTupleBitraverseInstances", "2.4.0")
47+
def catsBitraverseForTuple2: Bitraverse[Tuple2] = cats.instances.tuple.catsStdBitraverseForTuple2
4648

4749
/* ======================================================================== */
4850
/* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */

core/src/main/scala/cats/Bifunctor.scala

+4-3
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,11 @@ import scala.annotation.implicitNotFound
5959
def leftWiden[A, B, AA >: A](fab: F[A, B]): F[AA, B] = fab.asInstanceOf[F[AA, B]]
6060
}
6161

62-
object Bifunctor {
62+
object Bifunctor extends cats.instances.NTupleBifunctorInstances {
6363
implicit def catsBifunctorForEither: Bifunctor[Either] = cats.instances.either.catsStdBitraverseForEither
64-
implicit def catsBifunctorForTuple2: Bifunctor[Tuple2] = cats.instances.tuple.catsStdBitraverseForTuple2
64+
65+
@deprecated("Use catsStdBitraverseForTuple2 in cats.instances.NTupleBitraverseInstances", "2.4.0")
66+
def catsBifunctorForTuple2: Bifunctor[Tuple2] = cats.instances.tuple.catsStdBitraverseForTuple2
6567

6668
/* ======================================================================== */
6769
/* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */
@@ -108,7 +110,6 @@ object Bifunctor {
108110
/* ======================================================================== */
109111
/* END OF SIMULACRUM-MANAGED CODE */
110112
/* ======================================================================== */
111-
112113
}
113114

114115
private[cats] trait ComposedBifunctor[F[_, _], G[_, _]] extends Bifunctor[λ[(A, B) => F[G[A, B], G[A, B]]]] {

core/src/main/scala/cats/Invariant.scala

+13-7
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ import scala.util.control.TailCalls.TailRec
105105
@suppressUnusedImportWarningForScalaVersionSpecific
106106
object Invariant extends ScalaVersionSpecificInvariantInstances with InvariantInstances0 {
107107
implicit def catsInstancesForId: Distributive[Id] with Comonad[Id] = cats.catsInstancesForId
108-
implicit def catsComonadForTuple2[A]: Comonad[(A, *)] = cats.instances.tuple.catsStdInstancesForTuple2[A]
109108
implicit def catsMonadErrorForEither[A]: MonadError[Either[A, *], A] =
110109
cats.instances.either.catsStdInstancesForEither[A]
111110
implicit def catsInstancesForOption
@@ -238,6 +237,9 @@ object Invariant extends ScalaVersionSpecificInvariantInstances with InvariantIn
238237

239238
}
240239

240+
@deprecated("Use catsStdInstancesForTuple2 in cats.instances.NTupleMonadInstances", "2.4.0")
241+
def catsComonadForTuple2[A]: Comonad[(A, *)] = cats.instances.tuple.catsStdInstancesForTuple2[A]
242+
241243
/* ======================================================================== */
242244
/* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */
243245
/* ======================================================================== */
@@ -285,38 +287,42 @@ object Invariant extends ScalaVersionSpecificInvariantInstances with InvariantIn
285287
}
286288

287289
private[cats] trait InvariantInstances0 extends InvariantInstances1 {
288-
implicit def catsCommutativeMonadForTuple2[X](implicit X: CommutativeMonoid[X]): CommutativeMonad[(X, *)] =
289-
cats.instances.tuple.catsStdCommutativeMonadForTuple2[X]
290290
implicit def catsContravariantForFunction1[R]: Contravariant[* => R] =
291291
cats.instances.function.catsStdContravariantForFunction1[R]
292292
implicit def catsDistributiveForFunction0: Distributive[Function0] = cats.instances.function.function0Distributive
293293
implicit def catsDistributiveForFunction1[I]: Distributive[I => *] =
294294
cats.instances.function.catsStdDistributiveForFunction1[I]
295295

296+
@deprecated("Use catsStdCommutativeMonadForTuple2 in cats.instances.NTupleMonadInstances", "2.4.0")
297+
def catsCommutativeMonadForTuple2[X](implicit X: CommutativeMonoid[X]): CommutativeMonad[(X, *)] =
298+
cats.instances.tuple.catsStdCommutativeMonadForTuple2[X]
296299
}
297300

298301
private trait InvariantInstances1 extends InvariantInstances2 {
299302
implicit def catsMonadForFunction1[I]: Monad[I => *] = cats.instances.function.catsStdMonadForFunction1[I]
300303
}
301304

302-
private[cats] trait InvariantInstances2 extends TupleInstances0 {
305+
private[cats] trait InvariantInstances2 extends cats.instances.NTupleMonadInstances with TupleInstances0 {
303306
implicit def catsApplicativeForArrow[F[_, _], A](implicit F: Arrow[F]): Applicative[F[A, *]] =
304307
new ArrowApplicative[F, A](F)
305308
implicit def catsInstancesForSeq: Monad[Seq] with Alternative[Seq] with CoflatMap[Seq] =
306309
cats.instances.seq.catsStdInstancesForSeq
307310
}
308311

309312
private[cats] trait TupleInstances0 extends TupleInstances1 {
310-
implicit def catsCommutativeFlatMapForTuple2[X](implicit X: CommutativeSemigroup[X]): CommutativeFlatMap[(X, *)] =
313+
@deprecated("Use catsStdCommutativeFlatMapForTuple2 in cats.instances.NTupleMonadInstances", "2.4.0")
314+
def catsCommutativeFlatMapForTuple2[X](implicit X: CommutativeSemigroup[X]): CommutativeFlatMap[(X, *)] =
311315
cats.instances.tuple.catsStdCommutativeFlatMapForTuple2[X]
312316
}
313317

314318
private trait TupleInstances1 extends TupleInstances2 {
315-
implicit def catsMonadForTuple2[X](implicit X: Monoid[X]): Monad[(X, *)] =
319+
@deprecated("Use catsStdMonadForTuple2 in cats.instances.NTupleMonadInstances", "2.4.0")
320+
def catsMonadForTuple2[X](implicit X: Monoid[X]): Monad[(X, *)] =
316321
cats.instances.tuple.catsStdMonadForTuple2[X]
317322
}
318323

319324
private trait TupleInstances2 {
320-
implicit def catsFlatMapForTuple2[X](implicit X: Semigroup[X]): FlatMap[(X, *)] =
325+
@deprecated("Use catsStdFlatMapForTuple2 on cats.instances.NTupleMonadInstances", "2.4.0")
326+
def catsFlatMapForTuple2[X](implicit X: Semigroup[X]): FlatMap[(X, *)] =
321327
cats.instances.tuple.catsStdFlatMapForTuple2[X]
322328
}

core/src/main/scala/cats/Show.scala

+4-2
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,17 @@ object Show extends ScalaVersionSpecificShowInstances with ShowInstances {
9494
implicit def catsShowForQueue[A: Show]: Show[Queue[A]] = cats.instances.queue.catsStdShowForQueue[A]
9595
implicit def catsShowForEither[A: Show, B: Show]: Show[Either[A, B]] =
9696
cats.instances.either.catsStdShowForEither[A, B]
97-
implicit def catsShowForTuple2[A: Show, B: Show]: Show[(A, B)] = cats.instances.tuple.catsStdShowForTuple2[A, B]
9897
implicit def catsShowForSet[A: Show]: Show[Set[A]] = cats.instances.set.catsStdShowForSet[A]
9998
implicit def catsShowForMap[K: Show, V: Show]: Show[Map[K, V]] = cats.instances.map.catsStdShowForMap[K, V]
10099
implicit def catsShowForSortedSet[A: Show]: Show[SortedSet[A]] = cats.instances.sortedSet.catsStdShowForSortedSet[A]
101100
implicit def catsShowForSortedMap[K: Show, V: Show]: Show[SortedMap[K, V]] =
102101
cats.instances.sortedMap.catsStdShowForSortedMap[K, V]
102+
103+
@deprecated("Use catsStdShowForTuple2 in cats.instances.NTupleShowInstances", "2.4.0")
104+
def catsShowForTuple2[A: Show, B: Show]: Show[(A, B)] = cats.instances.tuple.catsStdShowForTuple2[A, B]
103105
}
104106

105-
private[cats] trait ShowInstances {
107+
private[cats] trait ShowInstances extends cats.instances.NTupleShowInstances {
106108
implicit def catsShowForFiniteDuration: Show[FiniteDuration] =
107109
cats.instances.finiteDuration.catsStdShowForFiniteDurationUnambiguous
108110
}

core/src/main/scala/cats/UnorderedFoldable.scala

+8-4
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,10 @@ import scala.annotation.implicitNotFound
7474
unorderedFoldMap(fa)(a => if (p(a)) 1L else 0L)
7575
}
7676

77-
object UnorderedFoldable extends ScalaVersionSpecificTraverseInstances {
77+
object UnorderedFoldable
78+
extends ScalaVersionSpecificTraverseInstances
79+
with cats.instances.NTupleUnorderedFoldableInstances {
80+
7881
private val orEvalMonoid: CommutativeMonoid[Eval[Boolean]] = new CommutativeMonoid[Eval[Boolean]] {
7982
val empty: Eval[Boolean] = Eval.False
8083

@@ -110,11 +113,12 @@ object UnorderedFoldable extends ScalaVersionSpecificTraverseInstances {
110113
cats.instances.map.catsStdInstancesForMap[K]
111114

112115
implicit def catsTraverseForEither[A]: Traverse[Either[A, *]] = cats.instances.either.catsStdInstancesForEither[A]
113-
implicit def catsInstancesForTuple[A]: Traverse[(A, *)] with Reducible[(A, *)] =
114-
cats.instances.tuple.catsStdInstancesForTuple2[A]
115-
116116
implicit def catsTraverseForTry: Traverse[Try] = cats.instances.try_.catsStdInstancesForTry
117117

118+
@deprecated("Use catsStdInstancesForTuple2 in cats.instances.NTupleMonadInstances", "2.4.0")
119+
def catsInstancesForTuple[A]: Traverse[(A, *)] with Reducible[(A, *)] =
120+
cats.instances.tuple.catsStdInstancesForTuple2[A]
121+
118122
/* ======================================================================== */
119123
/* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */
120124
/* ======================================================================== */

core/src/main/scala/cats/instances/tuple.scala

+14-7
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ private[instances] trait Tuple2InstancesBinCompat0 {
3333
}
3434

3535
sealed private[instances] trait Tuple2Instances extends Tuple2Instances1 {
36-
implicit val catsStdBitraverseForTuple2: Bitraverse[Tuple2] =
36+
@deprecated("Use catsStdBitraverseForTuple2 in cats.instances.NTupleBitraverseInstances", "2.4.0")
37+
val catsStdBitraverseForTuple2: Bitraverse[Tuple2] =
3738
new Bitraverse[Tuple2] {
3839
def bitraverse[G[_]: Applicative, A, B, C, D](fab: (A, B))(f: A => G[C], g: B => G[D]): G[(C, D)] =
3940
Applicative[G].tuple2(f(fab._1), g(fab._2))
@@ -47,13 +48,15 @@ sealed private[instances] trait Tuple2Instances extends Tuple2Instances1 {
4748
g(fab._2, f(fab._1, c))
4849
}
4950

50-
implicit def catsStdShowForTuple2[A, B](implicit aShow: Show[A], bShow: Show[B]): Show[(A, B)] =
51+
@deprecated("Use catsStdShowForTuple2 in cats.instances.NTupleShowInstances", "2.4.0")
52+
def catsStdShowForTuple2[A, B](implicit aShow: Show[A], bShow: Show[B]): Show[(A, B)] =
5153
new Show[(A, B)] {
5254
override def show(f: (A, B)): String =
5355
s"(${aShow.show(f._1)},${bShow.show(f._2)})"
5456
}
5557

56-
implicit def catsStdInstancesForTuple2[X]: Traverse[(X, *)] with Comonad[(X, *)] with Reducible[(X, *)] =
58+
@deprecated("Use catsStdInstancesForTuple2 in cats.instances.NTupleMonadInstances", "2.4.0")
59+
def catsStdInstancesForTuple2[X]: Traverse[(X, *)] with Comonad[(X, *)] with Reducible[(X, *)] =
5760
new Traverse[(X, *)] with Comonad[(X, *)] with Reducible[(X, *)] {
5861
def traverse[G[_], A, B](fa: (X, A))(f: A => G[B])(implicit G: Applicative[G]): G[(X, B)] =
5962
G.map(f(fa._2))((fa._1, _))
@@ -107,26 +110,30 @@ sealed private[instances] trait Tuple2Instances extends Tuple2Instances1 {
107110
}
108111

109112
sealed private[instances] trait Tuple2Instances1 extends Tuple2Instances2 {
110-
implicit def catsStdCommutativeMonadForTuple2[X](implicit MX: CommutativeMonoid[X]): CommutativeMonad[(X, *)] =
113+
@deprecated("Use catsStdCommutativeMonadForTuple2 in cats.instances.NTupleMonadInstances", "2.4.0")
114+
def catsStdCommutativeMonadForTuple2[X](implicit MX: CommutativeMonoid[X]): CommutativeMonad[(X, *)] =
111115
new FlatMapTuple2[X](MX) with CommutativeMonad[(X, *)] {
112116
def pure[A](a: A): (X, A) = (MX.empty, a)
113117
}
114118
}
115119

116120
sealed private[instances] trait Tuple2Instances2 extends Tuple2Instances3 {
117-
implicit def catsStdCommutativeFlatMapForTuple2[X](implicit MX: CommutativeSemigroup[X]): CommutativeFlatMap[(X, *)] =
121+
@deprecated("Use catsStdCommutativeFlatMapForTuple2 in cats.instances.NTupleMonadInstances", "2.4.0")
122+
def catsStdCommutativeFlatMapForTuple2[X](implicit MX: CommutativeSemigroup[X]): CommutativeFlatMap[(X, *)] =
118123
new FlatMapTuple2[X](MX) with CommutativeFlatMap[(X, *)]
119124
}
120125

121126
sealed private[instances] trait Tuple2Instances3 extends Tuple2Instances4 {
122-
implicit def catsStdMonadForTuple2[X](implicit MX: Monoid[X]): Monad[(X, *)] =
127+
@deprecated("Use catsStdMonadForTuple2 in cats.instances.NTupleMonadInstances", "2.4.0")
128+
def catsStdMonadForTuple2[X](implicit MX: Monoid[X]): Monad[(X, *)] =
123129
new FlatMapTuple2[X](MX) with Monad[(X, *)] {
124130
def pure[A](a: A): (X, A) = (MX.empty, a)
125131
}
126132
}
127133

128134
sealed private[instances] trait Tuple2Instances4 {
129-
implicit def catsStdFlatMapForTuple2[X](implicit SX: Semigroup[X]): FlatMap[(X, *)] =
135+
@deprecated("Use catsStdFlatMapForTuple2 on cats.instances.NTupleMonadInstances", "2.4.0")
136+
def catsStdFlatMapForTuple2[X](implicit SX: Semigroup[X]): FlatMap[(X, *)] =
130137
new FlatMapTuple2[X](SX)
131138
}
132139

project/Boilerplate.scala

+55-17
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import sbt._
22

3+
import scala.annotation.tailrec
4+
35
/**
46
* Copied, with some modifications, from https://github.com/milessabin/shapeless/blob/master/project/Boilerplate.scala
57
*
@@ -28,8 +30,13 @@ object Boilerplate {
2830
GenTupleSemigroupalSyntax,
2931
GenParallelArityFunctions,
3032
GenParallelArityFunctions2,
33+
GenFoldableArityFunctions,
3134
GenTupleParallelSyntax,
32-
GenFoldableArityFunctions
35+
GenTupleShowInstances,
36+
GenTupleMonadInstances,
37+
GenTupleBifunctorInstances,
38+
GenTupleBitraverseInstances,
39+
GenTupleUnorderedFoldableInstances
3340
)
3441

3542
val header = "// auto-generated boilerplate by /project/Boilerplate.scala" // TODO: put something meaningful here?
@@ -49,21 +56,58 @@ object Boilerplate {
4956
final class TemplateVals(val arity: Int) {
5057
val synTypes = (0 until arity).map(n => s"A$n")
5158
val synVals = (0 until arity).map(n => s"a$n")
52-
val synTypedVals = (synVals.zip(synTypes)).map { case (v, t) => v + ":" + t }
59+
val synTypedVals = synVals.zip(synTypes).map { case (v, t) => v + ":" + t }
5360
val `A..N` = synTypes.mkString(", ")
5461
val `a..n` = synVals.mkString(", ")
5562
val `_.._` = Seq.fill(arity)("_").mkString(", ")
56-
val `(A..N)` = if (arity == 1) "Tuple1[A]" else synTypes.mkString("(", ", ", ")")
63+
val `(A..N)` = if (arity == 1) "Tuple1[A0]" else synTypes.mkString("(", ", ", ")")
5764
val `(_.._)` = if (arity == 1) "Tuple1[_]" else Seq.fill(arity)("_").mkString("(", ", ", ")")
5865
val `(a..n)` = if (arity == 1) "Tuple1(a)" else synVals.mkString("(", ", ", ")")
5966
val `a:A..n:N` = synTypedVals.mkString(", ")
67+
68+
val `A..(N - 1)` = (0 until (arity - 1)).map(n => s"A$n")
69+
val `A..(N - 2)` = (0 until (arity - 2)).map(n => s"A$n")
70+
val `A0, A(N - 1)` = if (arity <= 1) "" else `A..(N - 1)`.mkString(", ")
71+
val `A0, A(N - 2)` = if (arity <= 2) "" else `A..(N - 2)`.mkString("", ", ", ", ")
72+
val `[A0, A(N - 2)]` = if (arity <= 2) "" else `A..(N - 2)`.mkString("[", ", ", "]")
73+
val `(A..N - 2, *, *)` =
74+
if (arity <= 2) "(*, *)"
75+
else `A..(N - 2)`.mkString("(", ", ", ", *, *)")
76+
val `a..(n - 1)` = (0 until (arity - 1)).map(n => s"a$n")
77+
val `fa._1..fa._(n - 2)` =
78+
if (arity <= 2) "" else (0 until (arity - 2)).map(n => s"fa._${n + 1}").mkString("", ", ", ", ")
79+
val `pure(fa._1..(n - 2))` =
80+
if (arity <= 2) "" else (0 until (arity - 2)).map(n => s"G.pure(fa._${n + 1})").mkString("", ", ", ", ")
81+
val `a0, a(n - 1)` = if (arity <= 1) "" else `a..(n - 1)`.mkString(", ")
82+
val `[A0, A(N - 1)]` = if (arity <= 1) "" else `A..(N - 1)`.mkString("[", ", ", "]")
83+
val `(A0, A(N - 1))` =
84+
if (arity == 1) "Tuple1[A0]"
85+
else if (arity == 2) "A0"
86+
else `A..(N - 1)`.mkString("(", ", ", ")")
87+
val `(A..N - 1, *)` =
88+
if (arity == 1) "Tuple1"
89+
else `A..(N - 1)`.mkString("(", ", ", ", *)")
90+
val `(fa._1..(n - 1))` =
91+
if (arity <= 1) "Tuple1.apply" else (0 until (arity - 1)).map(n => s"fa._${n + 1}").mkString("(", ", ", ", _)")
92+
93+
def `A0, A(N - 1)&`(a: String): String =
94+
if (arity <= 1) s"Tuple1[$a]" else `A..(N - 1)`.mkString("(", ", ", s", $a)")
95+
96+
def `fa._1..(n - 1) & `(a: String): String =
97+
if (arity <= 1) s"Tuple1($a)" else (0 until (arity - 1)).map(n => s"fa._${n + 1}").mkString("(", ", ", s", $a)")
98+
99+
def `constraints A..N`(c: String): String = synTypes.map(tpe => s"$tpe: $c[$tpe]").mkString("(implicit ", ", ", ")")
100+
def `constraints A..(N-1)`(c: String): String =
101+
if (arity <= 1) "" else `A..(N - 1)`.map(tpe => s"$tpe: $c[$tpe]").mkString("(implicit ", ", ", ")")
102+
def `parameters A..(N-1)`(c: String): String = `A..(N - 1)`.map(tpe => s"$tpe: $c[$tpe]").mkString(", ")
60103
}
61104

62105
trait Template {
63106
def filename(root: File): File
64107
def content(tv: TemplateVals): String
65108
def range = 1 to maxArity
66109
def body: String = {
110+
@tailrec
67111
def expandInstances(contents: IndexedSeq[Array[String]], acc: Array[String] = Array.empty): Array[String] =
68112
if (!contents.exists(_.exists(_.startsWith("-"))))
69113
acc.map(_.tail)
@@ -108,8 +152,7 @@ object Boilerplate {
108152
val tpes = synTypes.map { tpe =>
109153
s"F[$tpe]"
110154
}
111-
val tpesString = synTypes.mkString(", ")
112-
val params = (synVals.zip(tpes)).map { case (v, t) => s"$v:$t" }.mkString(", ")
155+
val params = synVals.zip(tpes).map { case (v, t) => s"$v:$t" }.mkString(", ")
113156
val next = if (arity + 1 <= maxArity) {
114157
s"def |@|[Z](z: F[Z]) = new SemigroupalBuilder${arity + 1}(${`a..n`}, z)"
115158
} else {
@@ -179,7 +222,7 @@ object Boilerplate {
179222
s"F[$tpe]"
180223
}
181224
val fargs = (0 until arity).map("f" + _)
182-
val fparams = (fargs.zip(tpes)).map { case (v, t) => s"$v:$t" }.mkString(", ")
225+
val fparams = fargs.zip(tpes).map { case (v, t) => s"$v:$t" }.mkString(", ")
183226

184227
val a = arity / 2
185228
val b = arity - a
@@ -258,8 +301,7 @@ object Boilerplate {
258301
s"M[$tpe]"
259302
}
260303
val fargs = (0 until arity).map("m" + _)
261-
val fparams = (fargs.zip(tpes)).map { case (v, t) => s"$v:$t" }.mkString(", ")
262-
val fargsS = fargs.mkString(", ")
304+
val fparams = fargs.zip(tpes).map { case (v, t) => s"$v:$t" }.mkString(", ")
263305
val nestedExpansion = ParallelNestedExpansions(arity)
264306

265307
block"""
@@ -291,8 +333,7 @@ object Boilerplate {
291333
s"M[$tpe]"
292334
}
293335
val fargs = (0 until arity).map("m" + _)
294-
val fparams = (fargs.zip(tpes)).map { case (v, t) => s"$v:$t" }.mkString(", ")
295-
val fargsS = fargs.mkString(", ")
336+
val fparams = fargs.zip(tpes).map { case (v, t) => s"$v:$t" }.mkString(", ")
296337
val nestedExpansion = ParallelNestedExpansions(arity)
297338

298339
block"""
@@ -324,7 +365,7 @@ object Boilerplate {
324365
s"F[$tpe]"
325366
}
326367
val fargs = (0 until arity).map("f" + _)
327-
val fparams = (fargs.zip(tpes)).map { case (v, t) => s"$v:$t" }.mkString(", ")
368+
val fparams = fargs.zip(tpes).map { case (v, t) => s"$v:$t" }.mkString(", ")
328369
val fargsS = fargs.mkString(", ")
329370

330371
val nestedProducts = (0 until (arity - 2))
@@ -392,7 +433,7 @@ object Boilerplate {
392433

393434
val tuple = s"Tuple$arity[$tpesString]"
394435
val tupleTpe = s"t$arity: $tuple"
395-
val tupleArgs = (1 to arity).map { case n => s"t$arity._$n" }.mkString(", ")
436+
val tupleArgs = (1 to arity).map(n => s"t$arity._$n").mkString(", ")
396437

397438
val n = if (arity == 1) {
398439
""
@@ -443,7 +484,7 @@ object Boilerplate {
443484

444485
val tuple = s"Tuple$arity[$tpesString]"
445486
val tupleTpe = s"t$arity: $tuple"
446-
val tupleArgs = (1 to arity).map { case n => s"t$arity._$n" }.mkString(", ")
487+
val tupleArgs = (1 to arity).map(n => s"t$arity._$n").mkString(", ")
447488

448489
val n = if (arity == 1) {
449490
""
@@ -485,8 +526,6 @@ object Boilerplate {
485526
|package cats
486527
|package syntax
487528
|
488-
|
489-
|
490529
|trait TupleSemigroupalSyntax {
491530
- implicit def catsSyntaxTuple${arity}Semigroupal[F[_], ${`A..N`}]($tupleTpe): Tuple${arity}SemigroupalOps[F, ${`A..N`}] = new Tuple${arity}SemigroupalOps(t$arity)
492531
|}
@@ -512,7 +551,6 @@ object Boilerplate {
512551

513552
val tupleTpe = (1 to arity).map(_ => "A").mkString("(", ", ", ")")
514553
def listXN(range: Range) = range.map("x" + _).mkString(" :: ")
515-
val reverseXN = listXN(1 to arity - 1)
516554
val tupleXN = (1 to arity).map("x" + _).mkString("(", ", ", ")")
517555

518556
block"""
@@ -550,7 +588,7 @@ object Boilerplate {
550588
- val (acc, l) = eval.value
551589
- l match {
552590
- case ${listXN(2 to arity)} :: Nil =>
553-
- Now(($tupleXN :: acc, ${listXN(1 to arity - 1)} :: Nil))
591+
- Now(($tupleXN :: acc, ${listXN(1 until arity)} :: Nil))
554592
- case l =>
555593
- Now((acc, x1 :: l))
556594
- }

0 commit comments

Comments
 (0)