From cd1aaecfaa94809f150df9a53d29150faeb7a0d6 Mon Sep 17 00:00:00 2001 From: Filippo Mariotti Date: Wed, 9 Jan 2019 03:02:23 +0100 Subject: [PATCH 1/6] Private val in value classes --- binCompatTest/src/main/scala/catsBC/MimaExceptions.scala | 3 ++- build.sbt | 1 + core/src/main/scala/cats/syntax/either.scala | 2 +- core/src/main/scala/cats/syntax/traverseFilter.scala | 2 +- kernel-laws/src/main/scala/cats/kernel/laws/package.scala | 2 +- laws/src/main/scala/cats/laws/package.scala | 2 +- project/Boilerplate.scala | 2 +- project/KernelBoiler.scala | 2 +- 8 files changed, 9 insertions(+), 7 deletions(-) diff --git a/binCompatTest/src/main/scala/catsBC/MimaExceptions.scala b/binCompatTest/src/main/scala/catsBC/MimaExceptions.scala index 3d955ebe50..aca0fc8786 100644 --- a/binCompatTest/src/main/scala/catsBC/MimaExceptions.scala +++ b/binCompatTest/src/main/scala/catsBC/MimaExceptions.scala @@ -24,6 +24,7 @@ object MimaExceptions { "blah".leftNec[Int], List(Some(4), None).nested, cats.data.EitherT.left[Int](Option("err")), - true.iterateUntilM(Option(_))(identity _) + true.iterateUntilM(Option(_))(identity _), + Either.catchOnly[NumberFormatException] { "foo".toInt } ) } diff --git a/build.sbt b/build.sbt index 2f8c58a968..dea25fcab5 100644 --- a/build.sbt +++ b/build.sbt @@ -321,6 +321,7 @@ def mimaSettings(moduleName: String) = exclude[DirectMissingMethodProblem]("cats.syntax.DistributiveOps.fa"), exclude[DirectMissingMethodProblem]("cats.syntax.EitherIdOps.obj"), exclude[DirectMissingMethodProblem]("cats.syntax.EitherIdOpsBinCompat0.value"), + exclude[DirectMissingMethodProblem]("cats.syntax.EitherSyntax#CatchOnlyPartiallyApplied.dummy"), exclude[DirectMissingMethodProblem]("cats.syntax.EitherKOps.fa"), exclude[DirectMissingMethodProblem]("cats.syntax.EitherObjectOps.either"), exclude[DirectMissingMethodProblem]("cats.syntax.EitherOps.eab"), diff --git a/core/src/main/scala/cats/syntax/either.scala b/core/src/main/scala/cats/syntax/either.scala index 9b4c92f834..deb606aac2 100644 --- a/core/src/main/scala/cats/syntax/either.scala +++ b/core/src/main/scala/cats/syntax/either.scala @@ -25,7 +25,7 @@ object EitherSyntax { /** * Uses the [[http://typelevel.org/cats/guidelines.html#partially-applied-type-params Partially Applied Type Params technique]] for ergonomics. */ - final private[syntax] class CatchOnlyPartiallyApplied[T](val dummy: Boolean = true) extends AnyVal { + final private[syntax] class CatchOnlyPartiallyApplied[T](private val dummy: Boolean = true) extends AnyVal { def apply[A](f: => A)(implicit CT: ClassTag[T], NT: NotNull[T]): Either[T, A] = try { Right(f) diff --git a/core/src/main/scala/cats/syntax/traverseFilter.scala b/core/src/main/scala/cats/syntax/traverseFilter.scala index 1763731702..29daa9eb56 100644 --- a/core/src/main/scala/cats/syntax/traverseFilter.scala +++ b/core/src/main/scala/cats/syntax/traverseFilter.scala @@ -8,7 +8,7 @@ trait TraverseFilterSyntaxBinCompat0 { new SequenceFilterOps(fgoa) } -final class SequenceFilterOps[F[_], G[_], A](val fgoa: F[G[Option[A]]]) extends AnyVal { +final class SequenceFilterOps[F[_], G[_], A](private val fgoa: F[G[Option[A]]]) extends AnyVal { /** * {{{ diff --git a/kernel-laws/src/main/scala/cats/kernel/laws/package.scala b/kernel-laws/src/main/scala/cats/kernel/laws/package.scala index 47a8f44621..6b2e9613ca 100644 --- a/kernel-laws/src/main/scala/cats/kernel/laws/package.scala +++ b/kernel-laws/src/main/scala/cats/kernel/laws/package.scala @@ -2,7 +2,7 @@ package cats.kernel package object laws { - implicit final class IsEqArrow[A](val lhs: A) extends AnyVal { + implicit final class IsEqArrow[A](private val lhs: A) extends AnyVal { def <->(rhs: A): IsEq[A] = IsEq(lhs, rhs) } } diff --git a/laws/src/main/scala/cats/laws/package.scala b/laws/src/main/scala/cats/laws/package.scala index 3b3a5d13d3..aafeffb16e 100644 --- a/laws/src/main/scala/cats/laws/package.scala +++ b/laws/src/main/scala/cats/laws/package.scala @@ -5,7 +5,7 @@ package object laws { type IsEq[A] = cats.kernel.laws.IsEq[A] val IsEq = cats.kernel.laws.IsEq - implicit final class IsEqArrow[A](val lhs: A) extends AnyVal { + implicit final class IsEqArrow[A](private val lhs: A) extends AnyVal { def <->(rhs: A): IsEq[A] = IsEq(lhs, rhs) } } diff --git a/project/Boilerplate.scala b/project/Boilerplate.scala index 8812df4165..11a99679a5 100644 --- a/project/Boilerplate.scala +++ b/project/Boilerplate.scala @@ -12,7 +12,7 @@ import sbt._ object Boilerplate { import scala.StringContext._ - implicit final class BlockHelper(val sc: StringContext) extends AnyVal { + implicit final class BlockHelper(private val sc: StringContext) extends AnyVal { def block(args: Any*): String = { val interpolated = sc.standardInterpolator(treatEscapes, args) val rawLines = interpolated.split('\n') diff --git a/project/KernelBoiler.scala b/project/KernelBoiler.scala index 95efe25eb5..4b35dcecb3 100644 --- a/project/KernelBoiler.scala +++ b/project/KernelBoiler.scala @@ -13,7 +13,7 @@ import sbt._ object KernelBoiler { import scala.StringContext._ - implicit class BlockHelper(val sc: StringContext) extends AnyVal { + implicit class BlockHelper(private val sc: StringContext) extends AnyVal { def block(args: Any*): String = { val interpolated = sc.standardInterpolator(treatEscapes, args) val rawLines = interpolated.split('\n') From ce95dd2d4aaca90a82ec27648918f7f492fc34f3 Mon Sep 17 00:00:00 2001 From: Filippo Mariotti Date: Mon, 14 Jan 2019 23:41:16 +0100 Subject: [PATCH 2/6] Added value classes to boilerplate syntax and mima exceptions --- build.sbt | 21 ++++++++++++++++++++- project/Boilerplate.scala | 4 ++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/build.sbt b/build.sbt index dea25fcab5..15c5074078 100644 --- a/build.sbt +++ b/build.sbt @@ -373,10 +373,29 @@ def mimaSettings(moduleName: String) = exclude[MissingTypesProblem]("cats.arrow.FunctionKMacros$"), exclude[IncompatibleMethTypeProblem]("cats.arrow.FunctionKMacros#Lifter.this"), exclude[IncompatibleResultTypeProblem]("cats.arrow.FunctionKMacros#Lifter.c") - ) + ) ++ mimaBoilerplateSyntaxExclusions(scalaVersion.value) } ) +def mimaBoilerplateSyntaxExclusions(scalaVersion: String) = { + import com.typesafe.tools.mima.core._ + import com.typesafe.tools.mima.core.ProblemFilters._ + + Seq( + exclude[IncompatibleResultTypeProblem]("cats.*.catsSyntaxTuple*Semigroupal"), + exclude[IncompatibleResultTypeProblem]("cats.*.catsSyntaxTuple*Parallel"), + ) ++ (CrossVersion.partialVersion(scalaVersion) match { + case Some((2, 11)) => + Seq( + exclude[DirectMissingMethodProblem]("cats.syntax.TupleSemigroupalSyntax.catsSyntaxTuple*Semigroupal"), + exclude[DirectMissingMethodProblem]("cats.syntax.TupleParallelSyntax.catsSyntaxTuple*Parallel"), + exclude[ReversedMissingMethodProblem]("cats.syntax.TupleSemigroupalSyntax.catsSyntaxTuple*Semigroupal"), + exclude[ReversedMissingMethodProblem]("cats.syntax.TupleParallelSyntax.catsSyntaxTuple*Parallel") + ) + case _ => Seq.empty + }) +} + lazy val docs = project .enablePlugins(MicrositesPlugin) .enablePlugins(ScalaUnidocPlugin) diff --git a/project/Boilerplate.scala b/project/Boilerplate.scala index 11a99679a5..a127bdbcb1 100644 --- a/project/Boilerplate.scala +++ b/project/Boilerplate.scala @@ -404,7 +404,7 @@ object Boilerplate { - implicit def catsSyntaxTuple${arity}Parallel[M[_], ${`A..N`}]($tupleTpe): Tuple${arity}ParallelOps[M, ${`A..N`}] = new Tuple${arity}ParallelOps(t$arity) |} | - -private[syntax] final class Tuple${arity}ParallelOps[M[_], ${`A..N`}]($tupleTpe) { + -private[syntax] final class Tuple${arity}ParallelOps[M[_], ${`A..N`}](private val $tupleTpe) extends AnyVal { - $parMap - $parTupled -} @@ -470,7 +470,7 @@ object Boilerplate { - implicit def catsSyntaxTuple${arity}Semigroupal[F[_], ${`A..N`}]($tupleTpe): Tuple${arity}SemigroupalOps[F, ${`A..N`}] = new Tuple${arity}SemigroupalOps(t$arity) |} | - -private[syntax] final class Tuple${arity}SemigroupalOps[F[_], ${`A..N`}]($tupleTpe) { + -private[syntax] final class Tuple${arity}SemigroupalOps[F[_], ${`A..N`}](private val $tupleTpe) extends AnyVal { - $map - $contramap - $imap From 23f2ba0a7c7f05b73dc90da6c71c16954a488b5b Mon Sep 17 00:00:00 2001 From: Filippo Mariotti Date: Wed, 16 Jan 2019 22:32:36 +0100 Subject: [PATCH 3/6] Foldable and reducible --- core/src/main/scala/cats/syntax/foldable.scala | 2 +- core/src/main/scala/cats/syntax/reducible.scala | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/scala/cats/syntax/foldable.scala b/core/src/main/scala/cats/syntax/foldable.scala index 93e130d142..2e3771b958 100644 --- a/core/src/main/scala/cats/syntax/foldable.scala +++ b/core/src/main/scala/cats/syntax/foldable.scala @@ -198,7 +198,7 @@ final class FoldableOps[F[_], A](private val fa: F[A]) extends AnyVal { } -final class FoldableOps0[F[_], A](val fa: F[A]) extends AnyVal { +final class FoldableOps0[F[_], A](private val fa: F[A]) extends AnyVal { /** * Fold implemented by mapping `A` values into `B` in a context `G` and then diff --git a/core/src/main/scala/cats/syntax/reducible.scala b/core/src/main/scala/cats/syntax/reducible.scala index 2fe183ad64..eeb17bc39d 100644 --- a/core/src/main/scala/cats/syntax/reducible.scala +++ b/core/src/main/scala/cats/syntax/reducible.scala @@ -15,7 +15,7 @@ trait ReducibleSyntaxBinCompat0 { new ReducibleOps0[F, A](fa) } -final class ReducibleOps0[F[_], A](val fa: F[A]) extends AnyVal { +final class ReducibleOps0[F[_], A](private val fa: F[A]) extends AnyVal { /** * Apply `f` to each element of `fa` and combine them using the From f1cc8d3fc30b31adf435ab71a0a37a099d2b72f2 Mon Sep 17 00:00:00 2001 From: Filippo Mariotti Date: Wed, 16 Jan 2019 23:56:24 +0100 Subject: [PATCH 4/6] Added bc test and refined syntax value classes --- .../main/scala/catsBC/MimaExceptions.scala | 37 ++++++++++--------- project/Boilerplate.scala | 2 +- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/binCompatTest/src/main/scala/catsBC/MimaExceptions.scala b/binCompatTest/src/main/scala/catsBC/MimaExceptions.scala index aca0fc8786..b335dc7500 100644 --- a/binCompatTest/src/main/scala/catsBC/MimaExceptions.scala +++ b/binCompatTest/src/main/scala/catsBC/MimaExceptions.scala @@ -8,23 +8,24 @@ object MimaExceptions { import cats.arrow.FunctionK // needs to be imported because of a hygiene problem def isBinaryCompatible = ( - cats.Monad[cats.data.OptionT[List, ?]], - cats.data.OptionT.catsDataTraverseForOptionT[List], - cats.data.Kleisli.catsDataCommutativeArrowForKleisliId, - cats.data.OptionT.catsDataMonoidKForOptionT[List], - cats.data.OptionT.catsDataMonoidForOptionT[List, Int], - cats.data.Kleisli.catsDataMonadForKleisliId[Int], - cats.data.Kleisli.catsDataCommutativeArrowForKleisli[Option], - cats.data.Kleisli.catsDataCommutativeFlatMapForKleisli[Option, Int], - cats.data.IRWST.catsDataStrongForIRWST[List, Int, Int, Int], - cats.data.OptionT.catsDataMonadErrorMonadForOptionT[List], - FunctionK.lift(headOption), - cats.data.OptionT.catsDataMonadErrorForOptionT[Either[String, ?], String], - cats.data.OptionT[Either[String, ?], Int](Right(Some(17))).ensure("error")(_ => true), - "blah".leftNec[Int], - List(Some(4), None).nested, - cats.data.EitherT.left[Int](Option("err")), - true.iterateUntilM(Option(_))(identity _), - Either.catchOnly[NumberFormatException] { "foo".toInt } + cats.Monad[cats.data.OptionT[List, ?]], + cats.data.OptionT.catsDataTraverseForOptionT[List], + cats.data.Kleisli.catsDataCommutativeArrowForKleisliId, + cats.data.OptionT.catsDataMonoidKForOptionT[List], + cats.data.OptionT.catsDataMonoidForOptionT[List, Int], + cats.data.Kleisli.catsDataMonadForKleisliId[Int], + cats.data.Kleisli.catsDataCommutativeArrowForKleisli[Option], + cats.data.Kleisli.catsDataCommutativeFlatMapForKleisli[Option, Int], + cats.data.IRWST.catsDataStrongForIRWST[List, Int, Int, Int], + cats.data.OptionT.catsDataMonadErrorMonadForOptionT[List], + FunctionK.lift(headOption), + cats.data.OptionT.catsDataMonadErrorForOptionT[Either[String, ?], String], + cats.data.OptionT[Either[String, ?], Int](Right(Some(17))).ensure("error")(_ => true), + "blah".leftNec[Int], + List(Some(4), None).nested, + cats.data.EitherT.left[Int](Option("err")), + true.iterateUntilM(Option(_))(identity _), + Either.catchOnly[NumberFormatException] { "foo".toInt }, + (1.asRight[String], 2.asRight[String], 3.asRight[String]) mapN (_ + _ + _) ) } diff --git a/project/Boilerplate.scala b/project/Boilerplate.scala index a127bdbcb1..6719445081 100644 --- a/project/Boilerplate.scala +++ b/project/Boilerplate.scala @@ -470,7 +470,7 @@ object Boilerplate { - implicit def catsSyntaxTuple${arity}Semigroupal[F[_], ${`A..N`}]($tupleTpe): Tuple${arity}SemigroupalOps[F, ${`A..N`}] = new Tuple${arity}SemigroupalOps(t$arity) |} | - -private[syntax] final class Tuple${arity}SemigroupalOps[F[_], ${`A..N`}](private val $tupleTpe) extends AnyVal { + -private[syntax] final class Tuple${arity}SemigroupalOps[F[_], ${`A..N`}]($tupleTpe) { - $map - $contramap - $imap From 0d832d4d00ee3a2680ee9c83d0444d1180ca8ceb Mon Sep 17 00:00:00 2001 From: Filippo Mariotti Date: Thu, 17 Jan 2019 00:26:37 +0100 Subject: [PATCH 5/6] Removed unneeded mima exceptions --- build.sbt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/build.sbt b/build.sbt index 15c5074078..ef8f81d674 100644 --- a/build.sbt +++ b/build.sbt @@ -382,14 +382,11 @@ def mimaBoilerplateSyntaxExclusions(scalaVersion: String) = { import com.typesafe.tools.mima.core.ProblemFilters._ Seq( - exclude[IncompatibleResultTypeProblem]("cats.*.catsSyntaxTuple*Semigroupal"), - exclude[IncompatibleResultTypeProblem]("cats.*.catsSyntaxTuple*Parallel"), + exclude[IncompatibleResultTypeProblem]("cats.*.catsSyntaxTuple*Parallel") ) ++ (CrossVersion.partialVersion(scalaVersion) match { case Some((2, 11)) => Seq( - exclude[DirectMissingMethodProblem]("cats.syntax.TupleSemigroupalSyntax.catsSyntaxTuple*Semigroupal"), exclude[DirectMissingMethodProblem]("cats.syntax.TupleParallelSyntax.catsSyntaxTuple*Parallel"), - exclude[ReversedMissingMethodProblem]("cats.syntax.TupleSemigroupalSyntax.catsSyntaxTuple*Semigroupal"), exclude[ReversedMissingMethodProblem]("cats.syntax.TupleParallelSyntax.catsSyntaxTuple*Parallel") ) case _ => Seq.empty From 46c0834d952954bd32c6adf21e591de1cd09ff32 Mon Sep 17 00:00:00 2001 From: Filippo Mariotti Date: Thu, 17 Jan 2019 00:46:56 +0100 Subject: [PATCH 6/6] Updated tests --- binCompatTest/src/main/scala/catsBC/MimaExceptions.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/binCompatTest/src/main/scala/catsBC/MimaExceptions.scala b/binCompatTest/src/main/scala/catsBC/MimaExceptions.scala index b335dc7500..e3fcf47d22 100644 --- a/binCompatTest/src/main/scala/catsBC/MimaExceptions.scala +++ b/binCompatTest/src/main/scala/catsBC/MimaExceptions.scala @@ -26,6 +26,6 @@ object MimaExceptions { cats.data.EitherT.left[Int](Option("err")), true.iterateUntilM(Option(_))(identity _), Either.catchOnly[NumberFormatException] { "foo".toInt }, - (1.asRight[String], 2.asRight[String], 3.asRight[String]) mapN (_ + _ + _) + (1.validNel[String], 2.validNel[String], 3.validNel[String]) mapN (_ + _ + _) ) }