From 22ffaa08abacf5b80b91d9c8fa470f3b57063f22 Mon Sep 17 00:00:00 2001 From: Kailuo Wang Date: Tue, 24 Jul 2018 14:54:53 -0400 Subject: [PATCH 01/20] wip - all dependencies updated. need a way to fix breaking API --- build.sbt | 94 +++++++------------ .../main/scala/cats/kernel/Semigroup.scala | 2 +- .../cats/kernel/instances/StaticMethods.scala | 4 +- project/plugins.sbt | 4 +- 4 files changed, 40 insertions(+), 64 deletions(-) diff --git a/build.sbt b/build.sbt index e8fa17bf43..09e37c38f9 100644 --- a/build.sbt +++ b/build.sbt @@ -13,7 +13,7 @@ lazy val scoverageSettings = Seq( organization in ThisBuild := "org.typelevel" lazy val kernelSettings = Seq( - scalacOptions ++= commonScalacOptions, + scalacOptions ++= commonScalacOptions(scalaVersion.value), resolvers ++= Seq( Resolver.sonatypeRepo("releases"), Resolver.sonatypeRepo("snapshots")), @@ -22,20 +22,27 @@ lazy val kernelSettings = Seq( scalacOptions in (Compile, doc) := (scalacOptions in (Compile, doc)).value.filter(_ != "-Xfatal-warnings") ) ++ warnUnusedImport ++ update2_12 ++ xlint + +def macroDependencies(scalaVersion: String) = + CrossVersion.partialVersion(scalaVersion) match { + case Some((2, minor)) if minor < 13 => Seq( + compilerPlugin("org.scalamacros" %% "paradise" % "2.1.0" cross CrossVersion.patch) + ) + case _ => Seq() + } + lazy val commonSettings = Seq( incOptions := incOptions.value.withLogRecompileOnMacro(false), - scalacOptions ++= commonScalacOptions, + scalacOptions ++= commonScalacOptions(scalaVersion.value), resolvers ++= Seq( "bintray/non" at "http://dl.bintray.com/non/maven", Resolver.sonatypeRepo("releases"), Resolver.sonatypeRepo("snapshots") ), libraryDependencies ++= Seq( - "com.github.mpilquist" %%% "simulacrum" % "0.12.0" % Provided, - "org.typelevel" %%% "machinist" % "0.6.4", - compilerPlugin("org.scalamacros" %% "paradise" % "2.1.0" cross CrossVersion.patch), - compilerPlugin("org.spire-math" %% "kind-projector" % "0.9.6") - ), + "com.github.mpilquist" %%% "simulacrum" % "0.13.0" % Provided, + "org.typelevel" %%% "machinist" % "0.6.5", + compilerPlugin("org.spire-math" %% "kind-projector" % "0.9.7")) ++ macroDependencies(scalaVersion.value), pomPostProcess := { (node: xml.Node) => new RuleTransformer(new RewriteRule { override def transform(node: xml.Node): Seq[xml.Node] = node match { @@ -95,22 +102,21 @@ lazy val includeGeneratedSrc: Setting[_] = { lazy val catsSettings = commonSettings ++ publishSettings ++ scoverageSettings -lazy val scalaCheckVersion = "1.13.5" -// 2.13.0-M3 workaround -//lazy val scalaTestVersion = "3.0.5" -lazy val disciplineVersion = "0.9.0" lazy val catalystsVersion = "0.6" -// 2.13.0-M3 workaround +// 2.13.0-M4 workarounds def scalatestVersion(scalaVersion: String): String = - CrossVersion.partialVersion(scalaVersion) match { - case Some((2, 13)) => "3.0.5-M1" - case _ => "3.0.5" - } + if (priorTo2_13(scalaVersion)) "3.0.5" else "3.0.6-SNAP1" + +def scalaCheckVersion(scalaVersion: String): String = + if (priorTo2_13(scalaVersion)) "1.13.5" else "1.14.0" + +def disciplineVersion(scalaVersion: String): String = + if (priorTo2_13(scalaVersion)) "0.9.0" else "0.10.0" lazy val disciplineDependencies = Seq( - libraryDependencies += "org.scalacheck" %%% "scalacheck" % scalaCheckVersion, - libraryDependencies += "org.typelevel" %%% "discipline" % disciplineVersion) + libraryDependencies += "org.scalacheck" %%% "scalacheck" % scalaCheckVersion(scalaVersion.value), + libraryDependencies += "org.typelevel" %%% "discipline" % disciplineVersion(scalaVersion.value)) lazy val testingDependencies = Seq( libraryDependencies += "org.typelevel" %%% "catalysts-platform" % catalystsVersion, @@ -310,9 +316,7 @@ lazy val core = crossProject(JSPlatform, JVMPlatform) .settings(catsSettings) .settings(sourceGenerators in Compile += (sourceManaged in Compile).map(Boilerplate.gen).taskValue) .settings(includeGeneratedSrc) - .configureCross(disableScoverage210Jvm) - .configureCross(disableScoverage210Js) - .settings(libraryDependencies += "org.scalacheck" %%% "scalacheck" % scalaCheckVersion % "test") + .settings(libraryDependencies += "org.scalacheck" %%% "scalacheck" % scalaCheckVersion(scalaVersion.value) % "test") .jsSettings(commonJsSettings) .jvmSettings(commonJvmSettings ++ mimaSettings("cats-core") ) @@ -325,7 +329,6 @@ lazy val laws = crossProject(JSPlatform, JVMPlatform) .settings(moduleName := "cats-laws", name := "Cats laws") .settings(catsSettings) .settings(disciplineDependencies) - .configureCross(disableScoverage210Jvm) .settings(testingDependencies) .jsSettings(commonJsSettings) .jvmSettings(commonJvmSettings) @@ -443,7 +446,6 @@ lazy val js = project .settings(moduleName := "cats-js") .settings(catsSettings) .settings(commonJsSettings) - .configure(disableScoverage210Js) .enablePlugins(ScalaJSPlugin) @@ -593,8 +595,8 @@ lazy val crossVersionSharedSources: Seq[Setting[_]] = } } -lazy val commonScalacOptions = Seq( - "-deprecation", +def commonScalacOptions(scalaVersion: String) = Seq( +// "-deprecation", "-encoding", "UTF-8", "-feature", "-language:existentials", @@ -602,13 +604,18 @@ lazy val commonScalacOptions = Seq( "-language:implicitConversions", "-language:experimental.macros", "-unchecked", - "-Xfatal-warnings", - "-Yno-adapted-args", +// "-Xfatal-warnings", "-Ywarn-dead-code", "-Ywarn-numeric-widen", "-Ywarn-value-discard", "-Xfuture" -) +) ++ (if(priorTo2_13(scalaVersion)) Seq("-Yno-adapted-args") else Seq()) + +def priorTo2_13(scalaVersion: String): Boolean = + CrossVersion.partialVersion(scalaVersion) match { + case Some((2, minor)) if minor < 13 => true + case _ => false + } lazy val sharedPublishSettings = Seq( releaseCrossBuild := true, @@ -665,37 +672,6 @@ lazy val credentialSettings = Seq( } yield Credentials("Sonatype Nexus Repository Manager", "oss.sonatype.org", username, password)).toSeq ) -def disableScoverage210Js(crossProject: CrossProject) = - crossProject - .jsSettings( - coverageEnabled := { - CrossVersion.partialVersion(scalaVersion.value) match { - case Some((2, 10)) => false - case _ => coverageEnabled.value - } - } - ) - -def disableScoverage210Js: Project ⇒ Project = p => - p.settings( - coverageEnabled := { - CrossVersion.partialVersion(scalaVersion.value) match { - case Some((2, 10)) => false - case _ => coverageEnabled.value - } - } - ) - -def disableScoverage210Jvm(crossProject: CrossProject) = - crossProject - .jvmSettings( - coverageEnabled := { - CrossVersion.partialVersion(scalaVersion.value) match { - case Some((2, 10)) => false - case _ => coverageEnabled.value - } - } - ) lazy val update2_12 = Seq( scalacOptions -= { diff --git a/kernel/src/main/scala/cats/kernel/Semigroup.scala b/kernel/src/main/scala/cats/kernel/Semigroup.scala index 36aaf67859..7b48da14d0 100644 --- a/kernel/src/main/scala/cats/kernel/Semigroup.scala +++ b/kernel/src/main/scala/cats/kernel/Semigroup.scala @@ -38,7 +38,7 @@ trait Semigroup[@sp(Int, Long, Float, Double) A] extends Any with Serializable { * If the sequence is empty, returns None. Otherwise, returns Some(total). */ def combineAllOption(as: TraversableOnce[A]): Option[A] = - as.reduceOption(combine) + as.iterator.reduceOption(combine) } abstract class SemigroupFunctions[S[T] <: Semigroup[T]] { diff --git a/kernel/src/main/scala/cats/kernel/instances/StaticMethods.scala b/kernel/src/main/scala/cats/kernel/instances/StaticMethods.scala index 4b47e9da24..07265c0832 100644 --- a/kernel/src/main/scala/cats/kernel/instances/StaticMethods.scala +++ b/kernel/src/main/scala/cats/kernel/instances/StaticMethods.scala @@ -12,8 +12,8 @@ object StaticMethods { override def size: Int = m.size def get(k: K): Option[V] = m.get(k) def iterator: Iterator[(K, V)] = m.iterator - def +[V2 >: V](kv: (K, V2)): Map[K, V2] = m.toMap + kv - def -(key: K): Map[K, V] = m.toMap - key + def updated[V2 >: V](key: K, value: V2): Map[K, V2] = m.toMap + ((key, value)) + def remove(key: K): Map[K, V] = m.toMap - key } // scalastyle:off return diff --git a/project/plugins.sbt b/project/plugins.sbt index 87b23127d6..53cb8b51d9 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -5,14 +5,14 @@ addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.0") addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.2.0") addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.3.3") addSbtPlugin("org.scalastyle" % "scalastyle-sbt-plugin" % "1.0.0") -addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.0-M3") +addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.0-SNAPSHOT") addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "0.9.3") addSbtPlugin("com.github.tkawachi" % "sbt-doctest" % "0.8.0") addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "2.0") addSbtPlugin("com.47deg" % "sbt-microsites" % "0.7.20") addSbtPlugin("com.dwijnand" % "sbt-travisci" % "1.1.1") addSbtPlugin("org.lyranthe.sbt" % "partial-unification" % "1.1.1") -addSbtPlugin("org.tpolecat" % "tut-plugin" % "0.6.4") +addSbtPlugin("org.tpolecat" % "tut-plugin" % "0.6.6") addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "0.5.0") addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "0.5.0") addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.23") From cae9e4b17367ab1d153cdfa328325d9d8f19a0a3 Mon Sep 17 00:00:00 2001 From: Kailuo Wang Date: Wed, 25 Jul 2018 14:00:59 -0400 Subject: [PATCH 02/20] wip kernel working, core compiles, doctests failing due to different string representation --- .jvmopts | 2 +- .travis.yml | 2 +- build.sbt | 59 ++++++++++++------- .../scala-2.12-/cats/compat/SortedSet.scala | 11 ++++ .../scala-2.13+/cats/compat/SortedSet.scala | 9 +++ .../main/scala/cats/NonEmptyTraverse.scala | 2 +- .../main/scala/cats/data/NonEmptySet.scala | 18 ++++-- core/src/main/scala/cats/data/OptionT.scala | 3 - .../main/scala/cats/instances/parallel.scala | 2 +- .../cats/kernel/compat/TraversableOnce.scala | 8 +++ .../kernel/compat/WrappedMutableMapBase.scala | 10 ++++ .../cats/kernel/compat/TraversableOnce.scala | 8 +++ .../kernel/compat/WrappedMutableMapBase.scala | 10 ++++ .../main/scala/cats/kernel/Semigroup.scala | 3 +- .../cats/kernel/instances/StaticMethods.scala | 14 ++--- project/plugins.sbt | 2 +- 16 files changed, 119 insertions(+), 44 deletions(-) create mode 100644 core/src/main/scala-2.12-/cats/compat/SortedSet.scala create mode 100644 core/src/main/scala-2.13+/cats/compat/SortedSet.scala create mode 100644 kernel/src/main/scala-2.12-/cats/kernel/compat/TraversableOnce.scala create mode 100644 kernel/src/main/scala-2.12-/cats/kernel/compat/WrappedMutableMapBase.scala create mode 100644 kernel/src/main/scala-2.13+/cats/kernel/compat/TraversableOnce.scala create mode 100644 kernel/src/main/scala-2.13+/cats/kernel/compat/WrappedMutableMapBase.scala diff --git a/.jvmopts b/.jvmopts index 2818a8b356..481b1cbd58 100644 --- a/.jvmopts +++ b/.jvmopts @@ -1,7 +1,7 @@ -Dfile.encoding=UTF8 -Xms1G -Xmx6G --XX:MaxMetaspaceSize=512M +-XX:MaxMetaspaceSize=2G -XX:ReservedCodeCacheSize=250M -XX:+TieredCompilation -XX:-UseGCOverheadLimit diff --git a/.travis.yml b/.travis.yml index b4a39701f0..80fc76e2c0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,9 +10,9 @@ git: depth: 9999 scala: + - 2.12.6 - 2.11.12 - 2.13.0-M4 - - 2.12.6 matrix: allow_failures: diff --git a/build.sbt b/build.sbt index 09e37c38f9..7987787fe9 100644 --- a/build.sbt +++ b/build.sbt @@ -12,17 +12,32 @@ lazy val scoverageSettings = Seq( organization in ThisBuild := "org.typelevel" -lazy val kernelSettings = Seq( +lazy val commonSettings = Seq( scalacOptions ++= commonScalacOptions(scalaVersion.value), + Compile / unmanagedSourceDirectories ++= { + val bd = baseDirectory.value + def extraDirs(suffix: String) = + CrossType.Pure.sharedSrcDir(bd, "main").toList map (f => file(f.getPath + suffix)) + CrossVersion.partialVersion(scalaVersion.value) match { + case Some((2, y)) if y <= 12 => + extraDirs("-2.12-") + case Some((2, y)) if y >= 13 => + extraDirs("-2.13+") + case _ => Nil + } + }, resolvers ++= Seq( Resolver.sonatypeRepo("releases"), Resolver.sonatypeRepo("snapshots")), fork in test := true, + libraryDependencies ++= Seq( + "org.scala-lang.modules" %% "scala-collection-compat" % "0.1.1"), parallelExecution in Test := false, scalacOptions in (Compile, doc) := (scalacOptions in (Compile, doc)).value.filter(_ != "-Xfatal-warnings") ) ++ warnUnusedImport ++ update2_12 ++ xlint + def macroDependencies(scalaVersion: String) = CrossVersion.partialVersion(scalaVersion) match { case Some((2, minor)) if minor < 13 => Seq( @@ -31,34 +46,33 @@ def macroDependencies(scalaVersion: String) = case _ => Seq() } -lazy val commonSettings = Seq( + +lazy val catsSettings = Seq( incOptions := incOptions.value.withLogRecompileOnMacro(false), - scalacOptions ++= commonScalacOptions(scalaVersion.value), resolvers ++= Seq( - "bintray/non" at "http://dl.bintray.com/non/maven", - Resolver.sonatypeRepo("releases"), - Resolver.sonatypeRepo("snapshots") + "bintray/non" at "http://dl.bintray.com/non/maven" ), libraryDependencies ++= Seq( - "com.github.mpilquist" %%% "simulacrum" % "0.13.0" % Provided, "org.typelevel" %%% "machinist" % "0.6.5", compilerPlugin("org.spire-math" %% "kind-projector" % "0.9.7")) ++ macroDependencies(scalaVersion.value), + +) ++ commonSettings ++ publishSettings ++ scoverageSettings ++ simulacrumSettings + + +lazy val simulacrumSettings = Seq( + libraryDependencies += "com.github.mpilquist" %%% "simulacrum" % "0.13.0" % Provided, pomPostProcess := { (node: xml.Node) => new RuleTransformer(new RewriteRule { override def transform(node: xml.Node): Seq[xml.Node] = node match { case e: xml.Elem if e.label == "dependency" && - e.child.exists(child => child.label == "groupId" && child.text == "com.github.mpilquist") && - e.child.exists(child => child.label == "artifactId" && child.text.startsWith("simulacrum_")) => Nil + e.child.exists(child => child.label == "groupId" && child.text == "com.github.mpilquist") && + e.child.exists(child => child.label == "artifactId" && child.text.startsWith("simulacrum_")) => Nil case _ => Seq(node) } }).transform(node).head - }, - fork in test := true, - parallelExecution in Test := false, - scalacOptions in (Compile, doc) := (scalacOptions in (Compile, doc)).value.filter(_ != "-Xfatal-warnings") -) ++ warnUnusedImport ++ update2_12 ++ xlint - + } +) lazy val tagName = Def.setting{ s"v${if (releaseUseGlobalVersion.value) (version in ThisBuild).value else version.value}" @@ -100,7 +114,6 @@ lazy val includeGeneratedSrc: Setting[_] = { } } -lazy val catsSettings = commonSettings ++ publishSettings ++ scoverageSettings lazy val catalystsVersion = "0.6" @@ -279,7 +292,7 @@ lazy val kernel = crossProject(JSPlatform, JVMPlatform, NativePlatform) .crossType(CrossType.Pure) .in(file("kernel")) .settings(moduleName := "cats-kernel", name := "Cats kernel") - .settings(kernelSettings) + .settings(commonSettings) .settings(publishSettings) .settings(scoverageSettings) .settings(sourceGenerators in Compile += (sourceManaged in Compile).map(KernelBoiler.gen).taskValue) @@ -296,7 +309,7 @@ lazy val kernelLaws = crossProject(JSPlatform, JVMPlatform) .crossType(CrossType.Pure) .in(file("kernel-laws")) .settings(moduleName := "cats-kernel-laws", name := "Cats kernel laws") - .settings(kernelSettings) + .settings(commonSettings) .settings(publishSettings) .settings(scoverageSettings) .settings(disciplineDependencies) @@ -596,7 +609,6 @@ lazy val crossVersionSharedSources: Seq[Setting[_]] = } def commonScalacOptions(scalaVersion: String) = Seq( -// "-deprecation", "-encoding", "UTF-8", "-feature", "-language:existentials", @@ -604,12 +616,17 @@ def commonScalacOptions(scalaVersion: String) = Seq( "-language:implicitConversions", "-language:experimental.macros", "-unchecked", -// "-Xfatal-warnings", "-Ywarn-dead-code", "-Ywarn-numeric-widen", "-Ywarn-value-discard", "-Xfuture" -) ++ (if(priorTo2_13(scalaVersion)) Seq("-Yno-adapted-args") else Seq()) +) ++ (if(priorTo2_13(scalaVersion)) Seq( + "-Yno-adapted-args", + "-Xfatal-warnings", //todo: add the following two back to 2.13 + "-deprecation" +) else Seq( + "-Ymacro-annotations" +)) def priorTo2_13(scalaVersion: String): Boolean = CrossVersion.partialVersion(scalaVersion) match { diff --git a/core/src/main/scala-2.12-/cats/compat/SortedSet.scala b/core/src/main/scala-2.12-/cats/compat/SortedSet.scala new file mode 100644 index 0000000000..f732921b56 --- /dev/null +++ b/core/src/main/scala-2.12-/cats/compat/SortedSet.scala @@ -0,0 +1,11 @@ +package cats +package compat + +import scala.collection.immutable + + +private[cats] object SortedSet { + def zipWithIndex[A](s: immutable.SortedSet[A])(implicit A: Ordering[A]): immutable.SortedSet[(A, Int)] = + s.zipWithIndex + +} diff --git a/core/src/main/scala-2.13+/cats/compat/SortedSet.scala b/core/src/main/scala-2.13+/cats/compat/SortedSet.scala new file mode 100644 index 0000000000..88d60e5561 --- /dev/null +++ b/core/src/main/scala-2.13+/cats/compat/SortedSet.scala @@ -0,0 +1,9 @@ +package cats +package compat + +import scala.collection.immutable + +private[cats] object SortedSet { + def zipWithIndex[A](s: immutable.SortedSet[A])(implicit A: Ordering[A]): immutable.SortedSet[(A, Int)] = + s.zipWithIndex.to(immutable.SortedSet) +} diff --git a/core/src/main/scala/cats/NonEmptyTraverse.scala b/core/src/main/scala/cats/NonEmptyTraverse.scala index 64527ef97c..100d731bc5 100644 --- a/core/src/main/scala/cats/NonEmptyTraverse.scala +++ b/core/src/main/scala/cats/NonEmptyTraverse.scala @@ -19,7 +19,7 @@ import simulacrum.typeclass * {{{ * scala> import cats.implicits._ * scala> import cats.data.NonEmptyList - * scala> def countWords(words: List[String]): Map[String, Int] = words.groupBy(identity).mapValues(_.length) + * scala> def countWords(words: List[String]): Map[String, Int] = words.groupBy(identity).map { case (k, v) => (k, v.length) } * scala> NonEmptyList.of(List("How", "do", "you", "fly"), List("What", "do", "you", "do")).nonEmptyTraverse(countWords) * res0: Map[String,cats.data.NonEmptyList[Int]] = Map(do -> NonEmptyList(1, 2), you -> NonEmptyList(1, 1)) * }}} diff --git a/core/src/main/scala/cats/data/NonEmptySet.scala b/core/src/main/scala/cats/data/NonEmptySet.scala index 8ad0a4ed9a..7b201e5f12 100644 --- a/core/src/main/scala/cats/data/NonEmptySet.scala +++ b/core/src/main/scala/cats/data/NonEmptySet.scala @@ -136,8 +136,11 @@ sealed class NonEmptySetOps[A](val value: NonEmptySet[A]) { /** * Applies f to all the elements */ - def map[B](f: A => B)(implicit B: Order[B]): NonEmptySet[B] = - NonEmptySetImpl.create(SortedSet(toSortedSet.map(f).to: _*)(B.toOrdering)) + def map[B](f: A => B)(implicit B: Order[B]): NonEmptySet[B] = { + implicit val bOrdering = B.toOrdering + NonEmptySetImpl.create(toSortedSet.map(f)) + } + /** * Converts this set to a `NonEmptyList`. @@ -338,14 +341,17 @@ sealed class NonEmptySetOps[A](val value: NonEmptySet[A]) { * res0: cats.data.NonEmptySet[String] = TreeSet(1A, 2B, 3C) * }}} */ - def zipWith[B, C](b: NonEmptySet[B])(f: (A, B) => C)(implicit C: Order[C]): NonEmptySet[C] = - NonEmptySetImpl.create(SortedSet((toSortedSet, b.toSortedSet).zipped.map(f).to: _*)(C.toOrdering)) + def zipWith[B, C](b: NonEmptySet[B])(f: (A, B) => C)(implicit C: Order[C]): NonEmptySet[C] = { + implicit val cOrdering = C.toOrdering + NonEmptySetImpl.create((toSortedSet, b.toSortedSet).zipped.map(f)) + } /** * Zips this `NonEmptySet` with its index. */ - def zipWithIndex: NonEmptySet[(A, Int)] = - NonEmptySetImpl.create(toSortedSet.zipWithIndex) + def zipWithIndex: NonEmptySet[(A, Int)] ={ + NonEmptySetImpl.create(cats.compat.SortedSet.zipWithIndex(toSortedSet)) + } /** * Groups elements inside this `NonEmptySet` according to the `Order` diff --git a/core/src/main/scala/cats/data/OptionT.scala b/core/src/main/scala/cats/data/OptionT.scala index 73fae37589..173828396a 100644 --- a/core/src/main/scala/cats/data/OptionT.scala +++ b/core/src/main/scala/cats/data/OptionT.scala @@ -214,9 +214,6 @@ object OptionT extends OptionTInstances { } private[data] sealed abstract class OptionTInstances extends OptionTInstances0 { - implicit def catsDataMonadForOptionT[F[_]](implicit F0: Monad[F]): Monad[OptionT[F, ?]] = - new OptionTMonad[F] { implicit val F = F0 } - implicit def catsDataFoldableForOptionT[F[_]](implicit F0: Foldable[F]): Foldable[OptionT[F, ?]] = new OptionTFoldable[F] { implicit val F = F0 } diff --git a/core/src/main/scala/cats/instances/parallel.scala b/core/src/main/scala/cats/instances/parallel.scala index 6200c573e6..e45f666fc1 100644 --- a/core/src/main/scala/cats/instances/parallel.scala +++ b/core/src/main/scala/cats/instances/parallel.scala @@ -28,7 +28,7 @@ trait ParallelInstances extends ParallelInstances1 { def applicative: Applicative[Nested[F, Option, ?]] = cats.data.Nested.catsDataApplicativeForNested[F, Option] - def monad: Monad[OptionT[M, ?]] = cats.data.OptionT.catsDataMonadForOptionT[M] + def monad: Monad[OptionT[M, ?]] = cats.data.OptionT.catsDataMonadErrorMonadForOptionT[M] def sequential: Nested[F, Option, ?] ~> OptionT[M, ?] = λ[Nested[F, Option, ?] ~> OptionT[M, ?]](nested => OptionT(P.sequential(nested.value))) diff --git a/kernel/src/main/scala-2.12-/cats/kernel/compat/TraversableOnce.scala b/kernel/src/main/scala-2.12-/cats/kernel/compat/TraversableOnce.scala new file mode 100644 index 0000000000..4685fd53e5 --- /dev/null +++ b/kernel/src/main/scala-2.12-/cats/kernel/compat/TraversableOnce.scala @@ -0,0 +1,8 @@ +package cats.kernel +package compat + + +private[kernel] object TraversableOnce { + def reduceOption[A, A1 >: A](as: TraversableOnce[A], op: (A1, A1) => A1): Option[A1] = + as.reduceOption(op) +} diff --git a/kernel/src/main/scala-2.12-/cats/kernel/compat/WrappedMutableMapBase.scala b/kernel/src/main/scala-2.12-/cats/kernel/compat/WrappedMutableMapBase.scala new file mode 100644 index 0000000000..80d570fe4a --- /dev/null +++ b/kernel/src/main/scala-2.12-/cats/kernel/compat/WrappedMutableMapBase.scala @@ -0,0 +1,10 @@ +package cats.kernel +package compat + +import scala.collection.mutable + + +private[kernel] abstract class WrappedMutableMapBase[K, V](m: mutable.Map[K, V]) extends Map[K, V] { + def +[V2 >: V](kv: (K, V2)): Map[K, V2] = m.toMap + kv + def -(key: K): Map[K, V] = m.toMap - key +} diff --git a/kernel/src/main/scala-2.13+/cats/kernel/compat/TraversableOnce.scala b/kernel/src/main/scala-2.13+/cats/kernel/compat/TraversableOnce.scala new file mode 100644 index 0000000000..9e33c1e857 --- /dev/null +++ b/kernel/src/main/scala-2.13+/cats/kernel/compat/TraversableOnce.scala @@ -0,0 +1,8 @@ +package cats.kernel +package compat + + +private[kernel] object TraversableOnce { + def reduceOption[A, A1 >: A](as: TraversableOnce[A], op: (A1, A1) => A1): Option[A1] = + as.iterator.reduceOption(op) +} diff --git a/kernel/src/main/scala-2.13+/cats/kernel/compat/WrappedMutableMapBase.scala b/kernel/src/main/scala-2.13+/cats/kernel/compat/WrappedMutableMapBase.scala new file mode 100644 index 0000000000..aee19bb29c --- /dev/null +++ b/kernel/src/main/scala-2.13+/cats/kernel/compat/WrappedMutableMapBase.scala @@ -0,0 +1,10 @@ +package cats.kernel +package compat + +import scala.collection.mutable + + +private[kernel] abstract class WrappedMutableMapBase[K, V](m: mutable.Map[K, V]) extends Map[K, V] { + def updated[V2 >: V](key: K, value: V2): Map[K, V2] = m.toMap + ((key, value)) + def remove(key: K): Map[K, V] = m.toMap - key +} diff --git a/kernel/src/main/scala/cats/kernel/Semigroup.scala b/kernel/src/main/scala/cats/kernel/Semigroup.scala index 7b48da14d0..76169e8de5 100644 --- a/kernel/src/main/scala/cats/kernel/Semigroup.scala +++ b/kernel/src/main/scala/cats/kernel/Semigroup.scala @@ -2,7 +2,6 @@ package cats.kernel import scala.{ specialized => sp } import scala.annotation.tailrec - /** * A semigroup is any set `A` with an associative operation (`combine`). */ @@ -38,7 +37,7 @@ trait Semigroup[@sp(Int, Long, Float, Double) A] extends Any with Serializable { * If the sequence is empty, returns None. Otherwise, returns Some(total). */ def combineAllOption(as: TraversableOnce[A]): Option[A] = - as.iterator.reduceOption(combine) + cats.kernel.compat.TraversableOnce.reduceOption(as, combine) } abstract class SemigroupFunctions[S[T] <: Semigroup[T]] { diff --git a/kernel/src/main/scala/cats/kernel/instances/StaticMethods.scala b/kernel/src/main/scala/cats/kernel/instances/StaticMethods.scala index 07265c0832..47df763c2e 100644 --- a/kernel/src/main/scala/cats/kernel/instances/StaticMethods.scala +++ b/kernel/src/main/scala/cats/kernel/instances/StaticMethods.scala @@ -1,4 +1,5 @@ -package cats.kernel +package cats +package kernel package instances import scala.collection.mutable @@ -8,12 +9,11 @@ object StaticMethods { def wrapMutableMap[K, V](m: mutable.Map[K, V]): Map[K, V] = new WrappedMutableMap(m) - private[kernel] class WrappedMutableMap[K, V](m: mutable.Map[K, V]) extends Map[K, V] { - override def size: Int = m.size - def get(k: K): Option[V] = m.get(k) - def iterator: Iterator[(K, V)] = m.iterator - def updated[V2 >: V](key: K, value: V2): Map[K, V2] = m.toMap + ((key, value)) - def remove(key: K): Map[K, V] = m.toMap - key + private[kernel] class WrappedMutableMap[K, V](m: mutable.Map[K, V]) + extends kernel.compat.WrappedMutableMapBase[K, V](m) { + override def size: Int = m.size + def get(k: K): Option[V] = m.get(k) + def iterator: Iterator[(K, V)] = m.iterator } // scalastyle:off return diff --git a/project/plugins.sbt b/project/plugins.sbt index 53cb8b51d9..c23d7fd39a 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -15,5 +15,5 @@ addSbtPlugin("org.lyranthe.sbt" % "partial-unification" % "1.1.1") addSbtPlugin("org.tpolecat" % "tut-plugin" % "0.6.6") addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "0.5.0") addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "0.5.0") -addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.23") +addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.24") addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.3.7") From c969fa99e7e3fa7d61807488a91ce5e007966bf7 Mon Sep 17 00:00:00 2001 From: Kailuo Wang Date: Wed, 25 Jul 2018 14:36:02 -0400 Subject: [PATCH 03/20] disable doctests on 2.13 for now --- build.sbt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 7987787fe9..504c783d3b 100644 --- a/build.sbt +++ b/build.sbt @@ -33,7 +33,11 @@ lazy val commonSettings = Seq( libraryDependencies ++= Seq( "org.scala-lang.modules" %% "scala-collection-compat" % "0.1.1"), parallelExecution in Test := false, - scalacOptions in (Compile, doc) := (scalacOptions in (Compile, doc)).value.filter(_ != "-Xfatal-warnings") + scalacOptions in (Compile, doc) := (scalacOptions in (Compile, doc)).value.filter(_ != "-Xfatal-warnings"), + doctestGenTests := { + val unchanged = doctestGenTests.value + if(priorTo2_13(scalaVersion.value)) unchanged else Nil + } ) ++ warnUnusedImport ++ update2_12 ++ xlint From 5d048932bf400d181031de9afcaa971a8e85c2dc Mon Sep 17 00:00:00 2001 From: Kailuo Wang Date: Thu, 26 Jul 2018 10:14:07 -0400 Subject: [PATCH 04/20] wip added catalysts dependencie --- build.sbt | 9 ++++++--- core/src/main/scala/cats/data/OptionT.scala | 8 ++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/build.sbt b/build.sbt index 504c783d3b..6f57462d8d 100644 --- a/build.sbt +++ b/build.sbt @@ -34,6 +34,7 @@ lazy val commonSettings = Seq( "org.scala-lang.modules" %% "scala-collection-compat" % "0.1.1"), parallelExecution in Test := false, scalacOptions in (Compile, doc) := (scalacOptions in (Compile, doc)).value.filter(_ != "-Xfatal-warnings"), + //todo: reenable doctests on 2.13 once it's officially released. it's disabled for now due to changes to the `toString` impl of collections doctestGenTests := { val unchanged = doctestGenTests.value if(priorTo2_13(scalaVersion.value)) unchanged else Nil @@ -119,9 +120,11 @@ lazy val includeGeneratedSrc: Setting[_] = { } -lazy val catalystsVersion = "0.6" // 2.13.0-M4 workarounds +def catalystsVersion(scalaVersion: String): String = + if (priorTo2_13(scalaVersion)) "0.6" else "0.7-SNAPSHOT" + def scalatestVersion(scalaVersion: String): String = if (priorTo2_13(scalaVersion)) "3.0.5" else "3.0.6-SNAP1" @@ -136,8 +139,8 @@ lazy val disciplineDependencies = Seq( libraryDependencies += "org.typelevel" %%% "discipline" % disciplineVersion(scalaVersion.value)) lazy val testingDependencies = Seq( - libraryDependencies += "org.typelevel" %%% "catalysts-platform" % catalystsVersion, - libraryDependencies += "org.typelevel" %%% "catalysts-macros" % catalystsVersion % "test", + libraryDependencies += "org.typelevel" %%% "catalysts-platform" % catalystsVersion(scalaVersion.value), + libraryDependencies += "org.typelevel" %%% "catalysts-macros" % catalystsVersion(scalaVersion.value) % "test", // 2.13.0-M3 workaround // libraryDependencies += "org.scalatest" %%% "scalatest" % scalaTestVersion % "test") libraryDependencies += "org.scalatest" %%% "scalatest" % scalatestVersion(scalaVersion.value) % "test") diff --git a/core/src/main/scala/cats/data/OptionT.scala b/core/src/main/scala/cats/data/OptionT.scala index 173828396a..f6b97ddac1 100644 --- a/core/src/main/scala/cats/data/OptionT.scala +++ b/core/src/main/scala/cats/data/OptionT.scala @@ -214,8 +214,8 @@ object OptionT extends OptionTInstances { } private[data] sealed abstract class OptionTInstances extends OptionTInstances0 { - implicit def catsDataFoldableForOptionT[F[_]](implicit F0: Foldable[F]): Foldable[OptionT[F, ?]] = - new OptionTFoldable[F] { implicit val F = F0 } + implicit def catsDataTraverseForOptionT[F[_]](implicit F0: Traverse[F]): Traverse[OptionT[F, ?]] = + new OptionTTraverse[F] with OptionTFunctor[F] { implicit val F = F0 } implicit def catsDataSemigroupForOptionT[F[_], A](implicit F0: Semigroup[F[Option[A]]]): Semigroup[OptionT[F, A]] = new OptionTSemigroup[F, A] { implicit val F = F0 } @@ -263,8 +263,8 @@ private[data] sealed abstract class OptionTInstances1 extends OptionTInstances2 } private[data] sealed abstract class OptionTInstances2 extends OptionTInstances3 { - implicit def catsDataTraverseForOptionT[F[_]](implicit F0: Traverse[F]): Traverse[OptionT[F, ?]] = - new OptionTTraverse[F] with OptionTFunctor[F] { implicit val F = F0 } + implicit def catsDataFoldableForOptionT[F[_]](implicit F0: Foldable[F]): Foldable[OptionT[F, ?]] = + new OptionTFoldable[F] { implicit val F = F0 } } private[data] sealed abstract class OptionTInstances3 { From e3cc9d07db26ee50d562822b2fe3339176069707 Mon Sep 17 00:00:00 2001 From: Kailuo Wang Date: Thu, 26 Jul 2018 22:05:56 -0400 Subject: [PATCH 05/20] cats tests passes --- build.sbt | 12 ++++- .../cats/data/IndexedReaderWriterStateT.scala | 14 +++--- core/src/main/scala/cats/data/IorT.scala | 36 ++++++------- core/src/main/scala/cats/data/Kleisli.scala | 50 ++++++++++--------- core/src/main/scala/cats/data/OneAnd.scala | 21 ++++---- core/src/main/scala/cats/data/OptionT.scala | 28 +++++------ project/plugins.sbt | 2 +- .../test/scala/cats/tests/FoldableSuite.scala | 2 +- .../src/test/scala/cats/tests/ListSuite.scala | 2 +- .../scala/cats/tests/NonEmptyListSuite.scala | 2 +- .../src/test/scala/cats/tests/SetSuite.scala | 4 -- 11 files changed, 93 insertions(+), 80 deletions(-) diff --git a/build.sbt b/build.sbt index 6f57462d8d..7f7710f0af 100644 --- a/build.sbt +++ b/build.sbt @@ -243,7 +243,17 @@ def mimaSettings(moduleName: String) = { Seq( mimaPreviousArtifacts := (mimaVersions(version.value) ++ extraVersions) .filterNot(excludedVersions.contains(_)) - .map(v => "org.typelevel" %% moduleName % v) + .map(v => "org.typelevel" %% moduleName % v), + + mimaBinaryIssueFilters ++= { + import com.typesafe.tools.mima.core._ + import com.typesafe.tools.mima.core.ProblemFilters._ + //Only seald abstract class are allowed here. + Seq( + exclude[DirectMissingMethodProblem]("cats.data.OptionTInstances.catsDataMonadForOptionT"), + exclude[DirectMissingMethodProblem]("cats.data.OptionTInstances2.catsDataTraverseForOptionT") + ) + } ) } diff --git a/core/src/main/scala/cats/data/IndexedReaderWriterStateT.scala b/core/src/main/scala/cats/data/IndexedReaderWriterStateT.scala index e78a6dddf9..c2df4efe87 100644 --- a/core/src/main/scala/cats/data/IndexedReaderWriterStateT.scala +++ b/core/src/main/scala/cats/data/IndexedReaderWriterStateT.scala @@ -441,9 +441,10 @@ private[data] abstract class RWSFunctions { } private[data] sealed abstract class IRWSTInstances extends IRWSTInstances1 { - implicit def catsDataProfunctorForIRWST[F[_], E, L, T](implicit F0: Functor[F]): Profunctor[IndexedReaderWriterStateT[F, E, L, ?, ?, T]] = - new IRWSTProfunctor[F, E, L, T] { - implicit def F: Functor[F] = F0 + + implicit def catsDataStrongForIRWST[F[_], E, L, T](implicit F0: Monad[F]): Strong[IndexedReaderWriterStateT[F, E, L, ?, ?, T]] = + new IRWSTStrong[F, E, L, T] { + implicit def F: Monad[F] = F0 } implicit def catsDataBifunctorForIRWST[F[_], E, L, SA](implicit F0: Functor[F]): Bifunctor[IndexedReaderWriterStateT[F, E, L, SA, ?, ?]] = @@ -477,10 +478,11 @@ private[data] sealed abstract class IRWSTInstances1 extends IRWSTInstances2 { implicit def L: Monoid[L] = L0 } - implicit def catsDataStrongForIRWST[F[_], E, L, T](implicit F0: Monad[F]): Strong[IndexedReaderWriterStateT[F, E, L, ?, ?, T]] = - new IRWSTStrong[F, E, L, T] { - implicit def F: Monad[F] = F0 + implicit def catsDataProfunctorForIRWST[F[_], E, L, T](implicit F0: Functor[F]): Profunctor[IndexedReaderWriterStateT[F, E, L, ?, ?, T]] = + new IRWSTProfunctor[F, E, L, T] { + implicit def F: Functor[F] = F0 } + } private[data] sealed abstract class IRWSTInstances2 extends IRWSTInstances3 { diff --git a/core/src/main/scala/cats/data/IorT.scala b/core/src/main/scala/cats/data/IorT.scala index f8b966f811..7afbff8d2d 100644 --- a/core/src/main/scala/cats/data/IorT.scala +++ b/core/src/main/scala/cats/data/IorT.scala @@ -416,25 +416,28 @@ private[data] abstract class IorTInstances extends IorTInstances1 { new IorTMonoid[F, A, B] { val F0: Monoid[F[Ior[A, B]]] = F } implicit def catsDataParallelForIorTWithParallelEffect[M[_], F[_], E] - (implicit P: Parallel[M, F], E: Semigroup[E]): Parallel[IorT[M, E, ?], IorT[F, E, ?]] = new Parallel[IorT[M, E, ?], IorT[F, E, ?]] - { - val parallel: IorT[M, E, ?] ~> IorT[F, E, ?] = λ[IorT[M, E, ?] ~> IorT[F, E, ?]](fm => IorT(P.parallel(fm.value))) - val sequential: IorT[F, E, ?] ~> IorT[M, E, ?] = λ[IorT[F, E, ?] ~> IorT[M, E, ?]](ff => IorT(P.sequential(ff.value))) + (implicit P: Parallel[M, F], E: Semigroup[E]) + : Parallel[IorT[M, E, ?], IorT[F, E, ?]] { type Dummy } + = new Parallel[IorT[M, E, ?], IorT[F, E, ?]] { + type Dummy // fix to make this one more specific than the catsDataParallelForIorTWithSequentialEffect, see https://github.com/typelevel/cats/pull/2335#issuecomment-408249775 - private[this] val FA: Applicative[F] = P.applicative - private[this] val IorA: Applicative[Ior[E, ?]] = Parallel[Ior[E, ?], Ior[E, ?]].applicative + val parallel: IorT[M, E, ?] ~> IorT[F, E, ?] = λ[IorT[M, E, ?] ~> IorT[F, E, ?]](fm => IorT(P.parallel(fm.value))) + val sequential: IorT[F, E, ?] ~> IorT[M, E, ?] = λ[IorT[F, E, ?] ~> IorT[M, E, ?]](ff => IorT(P.sequential(ff.value))) - val applicative: Applicative[IorT[F, E, ?]] = new Applicative[IorT[F, E, ?]] { - def pure[A](a: A): IorT[F, E, A] = IorT.pure(a)(FA) - def ap[A, B](ff: IorT[F, E, A => B])(fa: IorT[F, E, A]): IorT[F, E, B] = - IorT(FA.map2(ff.value, fa.value)((f, a) => IorA.ap(f)(a))) - } + private[this] val FA: Applicative[F] = P.applicative + private[this] val IorA: Applicative[Ior[E, ?]] = Parallel[Ior[E, ?], Ior[E, ?]].applicative - lazy val monad: Monad[IorT[M, E, ?]] = { - implicit def underlyingMonadM: Monad[M] = P.monad - Monad[IorT[M, E, ?]] + val applicative: Applicative[IorT[F, E, ?]] = new Applicative[IorT[F, E, ?]] { + def pure[A](a: A): IorT[F, E, A] = IorT.pure(a)(FA) + def ap[A, B](ff: IorT[F, E, A => B])(fa: IorT[F, E, A]): IorT[F, E, B] = + IorT(FA.map2(ff.value, fa.value)((f, a) => IorA.ap(f)(a))) + } + + lazy val monad: Monad[IorT[M, E, ?]] = { + implicit def underlyingMonadM: Monad[M] = P.monad + Monad[IorT[M, E, ?]] + } } - } implicit def catsDataDeferForIor[F[_], E](implicit F: Defer[F]): Defer[IorT[F, E, ?]] = new Defer[IorT[F, E, ?]] { @@ -457,8 +460,7 @@ private[data] abstract class IorTInstances1 extends IorTInstances2 { } implicit def catsDataParallelForIorTWithSequentialEffect[F[_], E] - (implicit F: Monad[F], E: Semigroup[E]): Parallel[IorT[F, E, ?], IorT[F, E, ?]] = new Parallel[IorT[F, E, ?], IorT[F, E, ?]] - { + (implicit F: Monad[F], E: Semigroup[E]): Parallel[IorT[F, E, ?], IorT[F, E, ?]] = new Parallel[IorT[F, E, ?], IorT[F, E, ?]] { private[this] val identityK: IorT[F, E, ?] ~> IorT[F, E, ?] = FunctionK.id private[this] val underlyingParallel: Parallel[Ior[E, ?], Ior[E, ?]] = Parallel[Ior[E, ?], Ior[E, ?]] diff --git a/core/src/main/scala/cats/data/Kleisli.scala b/core/src/main/scala/cats/data/Kleisli.scala index d53b6cc1b3..31dd14df48 100644 --- a/core/src/main/scala/cats/data/Kleisli.scala +++ b/core/src/main/scala/cats/data/Kleisli.scala @@ -156,15 +156,11 @@ private[data] sealed trait KleisliExplicitInstances { } private[data] sealed abstract class KleisliInstances extends KleisliInstances0 { - implicit def catsDataCommutativeMonadForKleisli[F[_], A](implicit F0: CommutativeMonad[F]): CommutativeMonad[Kleisli[F, A, ?]] = - new KleisliMonad[F, A] with CommutativeMonad[Kleisli[F, A, ?]] { - implicit def F: Monad[F] = F0 - } + implicit def catsDataMonadForKleisliId[A]: CommutativeMonad[Kleisli[Id, A, ?]] = + catsDataCommutativeMonadForKleisli[Id, A] - implicit def catsDataArrowChoiceForKleisli[F[_]](implicit M: Monad[F]): ArrowChoice[Kleisli[F, ?, ?]] = - new KleisliArrowChoice[F] { - def F: Monad[F] = M - } + implicit val catsDataCommutativeArrowForKleisliId: CommutativeArrow[Kleisli[Id, ?, ?]] = + catsDataCommutativeArrowForKleisli[Id] implicit def catsDataDeferForKleisli[F[_], A](implicit F: Defer[F]): Defer[Kleisli[F, A, ?]] = new Defer[Kleisli[F, A, ?]] { @@ -175,20 +171,28 @@ private[data] sealed abstract class KleisliInstances extends KleisliInstances0 { } } -private[data] sealed abstract class KleisliInstances0 extends KleisliInstances1 { +private[data] sealed abstract class KleisliInstances0 extends KleisliInstances0_5 { + + implicit def catsDataCommutativeArrowForKleisli[F[_]](implicit M: CommutativeMonad[F]): CommutativeArrow[Kleisli[F, ?, ?]] with ArrowChoice[Kleisli[F, ?, ?]] = + new KleisliCommutativeArrow[F] {def F: CommutativeMonad[F] = M } + + implicit def catsDataCommutativeMonadForKleisli[F[_], A](implicit F0: CommutativeMonad[F]): CommutativeMonad[Kleisli[F, A, ?]] = + new KleisliMonad[F, A] with CommutativeMonad[Kleisli[F, A, ?]] { + implicit def F: Monad[F] = F0 + } + +} + +private[data] sealed abstract class KleisliInstances0_5 extends KleisliInstances1 { implicit def catsDataMonoidForKleisli[F[_], A, B](implicit FB0: Monoid[F[B]]): Monoid[Kleisli[F, A, B]] = new KleisliMonoid[F, A, B] { def FB: Monoid[F[B]] = FB0 } implicit def catsDataMonadErrorForKleisli[F[_], A, E](implicit ME: MonadError[F, E]): MonadError[Kleisli[F, A, ?], E] = new KleisliMonadError[F, A, E] { def F: MonadError[F, E] = ME } - implicit def catsDataMonadForKleisliId[A]: CommutativeMonad[Kleisli[Id, A, ?]] = - // In an ideal world this would just be `catsDataCommutativeMonadForKleisli[Id, A]` - // but that method is higher in the hierarchy than this one, and it would - // take a substantial amount of moving stuff around to make this happen - // in a binary-compatible way. - new KleisliMonad[Id, A] with CommutativeMonad[Kleisli[Id, A, ?]] { - implicit def F: Monad[Id] = catsInstancesForId + implicit def catsDataArrowChoiceForKleisli[F[_]](implicit M: Monad[F]): ArrowChoice[Kleisli[F, ?, ?]] = + new KleisliArrowChoice[F] { + def F: Monad[F] = M } implicit def catsDataContravariantMonoidalForKleisli[F[_], A](implicit F0: ContravariantMonoidal[F]): ContravariantMonoidal[Kleisli[F, A, ?]] = @@ -222,11 +226,8 @@ private[data] sealed abstract class KleisliInstances1 extends KleisliInstances2 implicit def catsDataMonadForKleisli[F[_], A](implicit M: Monad[F]): Monad[Kleisli[F, A, ?]] = new KleisliMonad[F, A] { def F: Monad[F] = M } - implicit def catsDataCommutativeArrowForKleisli[F[_]](implicit M: CommutativeMonad[F]): CommutativeArrow[Kleisli[F, ?, ?]] with ArrowChoice[Kleisli[F, ?, ?]] = - new KleisliCommutativeArrow[F] {def F: CommutativeMonad[F] = M } - implicit val catsDataCommutativeArrowForKleisliId: CommutativeArrow[Kleisli[Id, ?, ?]] = - catsDataCommutativeArrowForKleisli[Id] + implicit def catsDataParallelForKleisli[F[_], M[_], A] (implicit P: Parallel[M, F]): Parallel[Kleisli[M, A, ?], Kleisli[F, A, ?]] = new Parallel[Kleisli[M, A, ?], Kleisli[F, A, ?]]{ @@ -258,8 +259,8 @@ private[data] sealed abstract class KleisliInstances3 extends KleisliInstances4 implicit def catsDataMonoidKForKleisli[F[_], A](implicit F0: MonoidK[F]): MonoidK[Kleisli[F, A, ?]] = new KleisliMonoidK[F, A] { def F: MonoidK[F] = F0 } - implicit def catsDataFlatMapForKleisli[F[_], A](implicit FM: FlatMap[F]): FlatMap[Kleisli[F, A, ?]] = - new KleisliFlatMap[F, A] { def F: FlatMap[F] = FM } + implicit def catsDataCommutativeFlatMapForKleisli[F[_], A](implicit F0: CommutativeFlatMap[F]): CommutativeFlatMap[Kleisli[F, A, ?]] = + new KleisliFlatMap[F, A] with CommutativeFlatMap[Kleisli[F, A, ?]] { val F: CommutativeFlatMap[F] = F0 } implicit def catsDataChoiceForKleisli[F[_]](implicit M: Monad[F]): Choice[Kleisli[F, ?, ?]] = new KleisliChoice[F] { def F: Monad[F] = M } @@ -284,8 +285,9 @@ private[data] sealed abstract class KleisliInstances4 extends KleisliInstances5 implicit def catsDataApplicativeErrorForKleisli[F[_], E, A](implicit F0: ApplicativeError[F, E]): ApplicativeError[Kleisli[F, A, ?], E] = new KleisliApplicativeError[F, A, E] { def F: ApplicativeError[F, E] = F0 } - implicit def catsDataCommutativeFlatMapForKleisli[F[_], A](implicit F0: CommutativeFlatMap[F]): CommutativeFlatMap[Kleisli[F, A, ?]] = - new KleisliFlatMap[F, A] with CommutativeFlatMap[Kleisli[F, A, ?]] { val F: CommutativeFlatMap[F] = F0 } + implicit def catsDataFlatMapForKleisli[F[_], A](implicit FM: FlatMap[F]): FlatMap[Kleisli[F, A, ?]] = + new KleisliFlatMap[F, A] { def F: FlatMap[F] = FM } + } private[data] sealed abstract class KleisliInstances5 extends KleisliInstances6 { diff --git a/core/src/main/scala/cats/data/OneAnd.scala b/core/src/main/scala/cats/data/OneAnd.scala index e5052a6761..3d4454f989 100644 --- a/core/src/main/scala/cats/data/OneAnd.scala +++ b/core/src/main/scala/cats/data/OneAnd.scala @@ -139,15 +139,6 @@ private[data] sealed abstract class OneAndInstances extends OneAndLowPriority0 { implicit def catsDataSemigroupForOneAnd[F[_]: Alternative, A]: Semigroup[OneAnd[F, A]] = catsDataSemigroupKForOneAnd[F].algebra - implicit def catsDataReducibleForOneAnd[F[_]](implicit F: Foldable[F]): Reducible[OneAnd[F, ?]] = - new NonEmptyReducible[OneAnd[F, ?], F] { - override def split[A](fa: OneAnd[F, A]): (A, F[A]) = (fa.head, fa.tail) - - override def get[A](fa: OneAnd[F, A])(idx: Long): Option[A] = - if (idx == 0L) Some(fa.head) else F.get(fa.tail)(idx - 1L) - - override def size[A](fa: OneAnd[F, A]): Long = 1 + F.size(fa.tail) - } implicit def catsDataMonadForOneAnd[F[_]](implicit monad: Monad[F], alternative: Alternative[F]): Monad[OneAnd[F, ?]] = new Monad[OneAnd[F, ?]] { @@ -269,9 +260,19 @@ private[data] sealed abstract class OneAndLowPriority1 extends OneAndLowPriority } } +private[data] sealed abstract class OneAndLowPriority0_5 extends OneAndLowPriority1 { + implicit def catsDataReducibleForOneAnd[F[_]](implicit F: Foldable[F]): Reducible[OneAnd[F, ?]] = + new NonEmptyReducible[OneAnd[F, ?], F] { + override def split[A](fa: OneAnd[F, A]): (A, F[A]) = (fa.head, fa.tail) -private[data] sealed abstract class OneAndLowPriority0 extends OneAndLowPriority1 { + override def get[A](fa: OneAnd[F, A])(idx: Long): Option[A] = + if (idx == 0L) Some(fa.head) else F.get(fa.tail)(idx - 1L) + + override def size[A](fa: OneAnd[F, A]): Long = 1 + F.size(fa.tail) + } +} +private[data] sealed abstract class OneAndLowPriority0 extends OneAndLowPriority0_5 { implicit def catsDataNonEmptyTraverseForOneAnd[F[_]](implicit F: Traverse[F], F2: Alternative[F]): NonEmptyTraverse[OneAnd[F, ?]] = new NonEmptyReducible[OneAnd[F, ?], F] with NonEmptyTraverse[OneAnd[F, ?]] { def nonEmptyTraverse[G[_], A, B](fa: OneAnd[F, A])(f: (A) => G[B])(implicit G: Apply[G]): G[OneAnd[F, B]] = { diff --git a/core/src/main/scala/cats/data/OptionT.scala b/core/src/main/scala/cats/data/OptionT.scala index f6b97ddac1..41241e9348 100644 --- a/core/src/main/scala/cats/data/OptionT.scala +++ b/core/src/main/scala/cats/data/OptionT.scala @@ -217,12 +217,12 @@ private[data] sealed abstract class OptionTInstances extends OptionTInstances0 { implicit def catsDataTraverseForOptionT[F[_]](implicit F0: Traverse[F]): Traverse[OptionT[F, ?]] = new OptionTTraverse[F] with OptionTFunctor[F] { implicit val F = F0 } - implicit def catsDataSemigroupForOptionT[F[_], A](implicit F0: Semigroup[F[Option[A]]]): Semigroup[OptionT[F, A]] = - new OptionTSemigroup[F, A] { implicit val F = F0 } - implicit def catsDataOrderForOptionT[F[_], A](implicit F0: Order[F[Option[A]]]): Order[OptionT[F, A]] = new OptionTOrder[F, A] { implicit val F = F0 } + implicit def catsDataMonoidForOptionT[F[_], A](implicit F0: Monoid[F[Option[A]]]): Monoid[OptionT[F, A]] = + new OptionTMonoid[F, A] { implicit val F = F0 } + implicit def catsDataShowForOptionT[F[_], A](implicit F: Show[F[Option[A]]]): Show[OptionT[F, A]] = Contravariant[Show].contramap(F)(_.value) @@ -234,32 +234,32 @@ private[data] sealed abstract class OptionTInstances extends OptionTInstances0 { } private[data] sealed abstract class OptionTInstances0 extends OptionTInstances1 { - implicit def catsDataMonadErrorForOptionT[F[_], E](implicit F0: MonadError[F, E]): MonadError[OptionT[F, ?], E] = - new OptionTMonadError[F, E] { implicit val F = F0 } + implicit def catsDataMonadErrorMonadForOptionT[F[_]](implicit F0: Monad[F]): MonadError[OptionT[F, ?], Unit] = + new OptionTMonadErrorMonad[F] { implicit val F = F0 } implicit def catsDataContravariantMonoidalForOptionT[F[_]](implicit F0: ContravariantMonoidal[F]): ContravariantMonoidal[OptionT[F, ?]] = new OptionTContravariantMonoidal[F] { implicit val F = F0 } - implicit def catsDataSemigroupKForOptionT[F[_]](implicit F0: Monad[F]): SemigroupK[OptionT[F, ?]] = - new OptionTSemigroupK[F] { implicit val F = F0 } + implicit def catsDataMonoidKForOptionT[F[_]](implicit F0: Monad[F]): MonoidK[OptionT[F, ?]] = + new OptionTMonoidK[F] { implicit val F = F0 } - implicit def catsDataMonoidForOptionT[F[_], A](implicit F0: Monoid[F[Option[A]]]): Monoid[OptionT[F, A]] = - new OptionTMonoid[F, A] { implicit val F = F0 } + implicit def catsDataSemigroupForOptionT[F[_], A](implicit F0: Semigroup[F[Option[A]]]): Semigroup[OptionT[F, A]] = + new OptionTSemigroup[F, A] { implicit val F = F0 } implicit def catsDataPartialOrderForOptionT[F[_], A](implicit F0: PartialOrder[F[Option[A]]]): PartialOrder[OptionT[F, A]] = new OptionTPartialOrder[F, A] { implicit val F = F0 } } private[data] sealed abstract class OptionTInstances1 extends OptionTInstances2 { - - implicit def catsDataMonoidKForOptionT[F[_]](implicit F0: Monad[F]): MonoidK[OptionT[F, ?]] = - new OptionTMonoidK[F] { implicit val F = F0 } + implicit def catsDataSemigroupKForOptionT[F[_]](implicit F0: Monad[F]): SemigroupK[OptionT[F, ?]] = + new OptionTSemigroupK[F] { implicit val F = F0 } implicit def catsDataEqForOptionT[F[_], A](implicit F0: Eq[F[Option[A]]]): Eq[OptionT[F, A]] = new OptionTEq[F, A] { implicit val F = F0 } - implicit def catsDataMonadErrorMonadForOptionT[F[_]](implicit F0: Monad[F]): MonadError[OptionT[F, ?], Unit] = - new OptionTMonadErrorMonad[F] { implicit val F = F0 } + implicit def catsDataMonadErrorForOptionT[F[_], E](implicit F0: MonadError[F, E]): MonadError[OptionT[F, ?], E] = + new OptionTMonadError[F, E] { implicit val F = F0 } + } private[data] sealed abstract class OptionTInstances2 extends OptionTInstances3 { diff --git a/project/plugins.sbt b/project/plugins.sbt index c23d7fd39a..3679d7e1e7 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -2,7 +2,7 @@ addSbtCoursier addSbtPlugin("com.eed3si9n" % "sbt-unidoc" % "0.4.1") addSbtPlugin("com.github.gseitz" %% "sbt-release" % "1.0.8") addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.0") -addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.2.0") +addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.3.0") addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.3.3") addSbtPlugin("org.scalastyle" % "scalastyle-sbt-plugin" % "1.0.0") addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.0-SNAPSHOT") diff --git a/tests/src/test/scala/cats/tests/FoldableSuite.scala b/tests/src/test/scala/cats/tests/FoldableSuite.scala index 1de57ae8c7..09fab7b113 100644 --- a/tests/src/test/scala/cats/tests/FoldableSuite.scala +++ b/tests/src/test/scala/cats/tests/FoldableSuite.scala @@ -227,7 +227,7 @@ class FoldableSuiteAdditional extends CatsSuite { } test("Foldable[SortedSet].foldM stack safety") { - checkFoldMStackSafety[SortedSet](_.to) + checkFoldMStackSafety[SortedSet](s => SortedSet(s:_*)) } test("Foldable[SortedMap[String, ?]].foldM stack safety") { diff --git a/tests/src/test/scala/cats/tests/ListSuite.scala b/tests/src/test/scala/cats/tests/ListSuite.scala index 805f9b8b45..a75de04879 100644 --- a/tests/src/test/scala/cats/tests/ListSuite.scala +++ b/tests/src/test/scala/cats/tests/ListSuite.scala @@ -36,7 +36,7 @@ class ListSuite extends CatsSuite { test("groupByNel should be consistent with groupBy")( forAll { (fa: List[Int], f: Int => Int) => - fa.groupByNel(f).mapValues(_.toList) should === (fa.groupBy(f)) + fa.groupByNel(f).map{ case (k, v) => (k, v.toList)} should === (fa.groupBy(f)) } ) diff --git a/tests/src/test/scala/cats/tests/NonEmptyListSuite.scala b/tests/src/test/scala/cats/tests/NonEmptyListSuite.scala index 578036773d..ffc184a220 100644 --- a/tests/src/test/scala/cats/tests/NonEmptyListSuite.scala +++ b/tests/src/test/scala/cats/tests/NonEmptyListSuite.scala @@ -275,7 +275,7 @@ class NonEmptyListSuite extends CatsSuite { test("NonEmptyList#groupBy is consistent with List#groupBy") { forAll { (nel: NonEmptyList[Int], f: Int => Int) => - nel.groupBy(f).mapValues(_.toList) should === (nel.toList.groupBy(f)) + nel.groupBy(f).map{ case (k, v) => (k, v.toList) } should === (nel.toList.groupBy(f)) } } diff --git a/tests/src/test/scala/cats/tests/SetSuite.scala b/tests/src/test/scala/cats/tests/SetSuite.scala index a83764f2ed..c8724cb124 100644 --- a/tests/src/test/scala/cats/tests/SetSuite.scala +++ b/tests/src/test/scala/cats/tests/SetSuite.scala @@ -18,10 +18,6 @@ class SetSuite extends CatsSuite { test("show"){ Set(1, 1, 2, 3).show should === ("Set(1, 2, 3)") Set.empty[String].show should === ("Set()") - - forAll { fs: Set[String] => - fs.show should === (fs.toString) - } } test("show keeps separate entries for items that map to identical strings"){ From 44a6ade012349b9f39541ea923814d0071585944 Mon Sep 17 00:00:00 2001 From: Kailuo Wang Date: Thu, 26 Jul 2018 22:25:22 -0400 Subject: [PATCH 06/20] fix mima --- .travis.yml | 8 +------- build.sbt | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index 80fc76e2c0..226784c496 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,15 +10,9 @@ git: depth: 9999 scala: - - 2.12.6 - 2.11.12 - 2.13.0-M4 - -matrix: - allow_failures: - # There are known issues in this scala milestone release that prevent the tests to compile. - # But we want to enable the build to facilitate debuging, esp on the community build. - - scala: 2.13.0-M4 + - 2.12.6 jdk: - oraclejdk8 diff --git a/build.sbt b/build.sbt index 7f7710f0af..5c874a5ce1 100644 --- a/build.sbt +++ b/build.sbt @@ -241,17 +241,26 @@ def mimaSettings(moduleName: String) = { lazy val extraVersions: Set[String] = Set() Seq( - mimaPreviousArtifacts := (mimaVersions(version.value) ++ extraVersions) - .filterNot(excludedVersions.contains(_)) - .map(v => "org.typelevel" %% moduleName % v), + mimaPreviousArtifacts := { if(priorTo2_13(scalaVersion.value)) { + (mimaVersions(version.value) ++ extraVersions) + .filterNot(excludedVersions.contains(_)) + .map(v => "org.typelevel" %% moduleName % v) + } else Set() }, mimaBinaryIssueFilters ++= { import com.typesafe.tools.mima.core._ import com.typesafe.tools.mima.core.ProblemFilters._ - //Only seald abstract class are allowed here. + //Only sealed abstract classes that provide implicit instances to companion objects are allowed here, since they don't affect usage outside of the file. Seq( exclude[DirectMissingMethodProblem]("cats.data.OptionTInstances.catsDataMonadForOptionT"), - exclude[DirectMissingMethodProblem]("cats.data.OptionTInstances2.catsDataTraverseForOptionT") + exclude[DirectMissingMethodProblem]("cats.data.OptionTInstances2.catsDataTraverseForOptionT"), + exclude[DirectMissingMethodProblem]("cats.data.KleisliInstances1.catsDataCommutativeArrowForKleisliId"), + exclude[DirectMissingMethodProblem]("cats.data.OptionTInstances1.catsDataMonoidKForOptionT"), + exclude[DirectMissingMethodProblem]("cats.data.OptionTInstances0.catsDataMonoidForOptionT"), + exclude[DirectMissingMethodProblem]("cats.data.KleisliInstances0.catsDataMonadForKleisliId"), + exclude[DirectMissingMethodProblem]("cats.data.KleisliInstances1.catsDataCommutativeArrowForKleisli"), + exclude[DirectMissingMethodProblem]("cats.data.KleisliInstances4.catsDataCommutativeFlatMapForKleisli"), + exclude[DirectMissingMethodProblem]("cats.data.IRWSTInstances1.catsDataStrongForIRWST") ) } ) From 94c4a02d00736bc1f88fc7481e5e03f7ab200390 Mon Sep 17 00:00:00 2001 From: Kailuo Wang Date: Fri, 27 Jul 2018 13:06:35 -0400 Subject: [PATCH 07/20] minor removed old 2.10 specific settings --- build.sbt | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/build.sbt b/build.sbt index 5c874a5ce1..f3787f38ff 100644 --- a/build.sbt +++ b/build.sbt @@ -695,14 +695,7 @@ lazy val sharedReleaseProcess = Seq( ) lazy val warnUnusedImport = Seq( - scalacOptions ++= { - CrossVersion.partialVersion(scalaVersion.value) match { - case Some((2, 10)) => - Seq() - case Some((2, n)) if n >= 11 => - Seq("-Ywarn-unused-import") - } - }, + scalacOptions ++= Seq("-Ywarn-unused-import"), scalacOptions in (Compile, console) ~= {_.filterNot("-Ywarn-unused-import" == _)}, scalacOptions in (Test, console) := (scalacOptions in (Compile, console)).value ) From f21ad1d2dbdfdda9f87d5362e8f57230bd7db796 Mon Sep 17 00:00:00 2001 From: Kailuo Wang Date: Fri, 27 Jul 2018 14:28:53 -0400 Subject: [PATCH 08/20] updated alleycats --- .../alleycats/compat/IterableEmptyInstance.scala | 9 +++++++++ .../alleycats/compat/IterableEmptyInstance.scala | 9 +++++++++ alleycats-core/src/main/scala/alleycats/Empty.scala | 5 +---- 3 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 alleycats-core/src/main/scala-2.12-/alleycats/compat/IterableEmptyInstance.scala create mode 100644 alleycats-core/src/main/scala-2.13+/alleycats/compat/IterableEmptyInstance.scala diff --git a/alleycats-core/src/main/scala-2.12-/alleycats/compat/IterableEmptyInstance.scala b/alleycats-core/src/main/scala-2.12-/alleycats/compat/IterableEmptyInstance.scala new file mode 100644 index 0000000000..f46a9595c4 --- /dev/null +++ b/alleycats-core/src/main/scala-2.12-/alleycats/compat/IterableEmptyInstance.scala @@ -0,0 +1,9 @@ +package alleycats +package compat + +import scala.collection.generic.CanBuildFrom + +abstract class IterableEmptyInstance { + implicit def iterableIsEmpty[CC[X] <: Iterable[X], A](implicit cbf: CanBuildFrom[CC[A], A, CC[A]]): Empty[CC[A]] = + Empty(cbf().result) +} diff --git a/alleycats-core/src/main/scala-2.13+/alleycats/compat/IterableEmptyInstance.scala b/alleycats-core/src/main/scala-2.13+/alleycats/compat/IterableEmptyInstance.scala new file mode 100644 index 0000000000..fa2c84558a --- /dev/null +++ b/alleycats-core/src/main/scala-2.13+/alleycats/compat/IterableEmptyInstance.scala @@ -0,0 +1,9 @@ +package alleycats +package compat + +import collection.Factory + +abstract class IterableEmptyInstance { + implicit def iterableIsEmpty[CC[X] <: Iterable[X], A](implicit factory: Factory[A, CC[A]]): Empty[CC[A]] = + Empty(factory.newBuilder.result) +} diff --git a/alleycats-core/src/main/scala/alleycats/Empty.scala b/alleycats-core/src/main/scala/alleycats/Empty.scala index b74ea2b052..810168940b 100644 --- a/alleycats-core/src/main/scala/alleycats/Empty.scala +++ b/alleycats-core/src/main/scala/alleycats/Empty.scala @@ -21,10 +21,7 @@ object Empty extends EmptyInstances0 { new Empty[A] { lazy val empty: A = a } } -trait EmptyInstances0 extends EmptyInstances1 { - implicit def iterableIsEmpty[CC[X] <: Iterable[X], A](implicit cbf: CanBuildFrom[CC[A], A, CC[A]]): Empty[CC[A]] = - Empty(cbf().result) -} +trait EmptyInstances0 extends compat.IterableEmptyInstance with EmptyInstances1 trait EmptyInstances1 extends EmptyInstances2 { // If Monoid extended Empty then this could be an exported subclass instance provided by Monoid From 855f730b9c34b6a006cc779d56c2f7755cef8bda Mon Sep 17 00:00:00 2001 From: Kailuo Wang Date: Fri, 27 Jul 2018 15:21:46 -0400 Subject: [PATCH 09/20] disable scoverage on 2.13 --- build.sbt | 6 ++++++ project/plugins.sbt | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index f3787f38ff..7678288e51 100644 --- a/build.sbt +++ b/build.sbt @@ -26,6 +26,12 @@ lazy val commonSettings = Seq( case _ => Nil } }, + coverageEnabled := { + if(priorTo2_13(scalaVersion.value)) + coverageEnabled.value + else + false + } , resolvers ++= Seq( Resolver.sonatypeRepo("releases"), Resolver.sonatypeRepo("snapshots")), diff --git a/project/plugins.sbt b/project/plugins.sbt index 3679d7e1e7..97335ba740 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -5,7 +5,7 @@ addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.0") addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.3.0") addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.3.3") addSbtPlugin("org.scalastyle" % "scalastyle-sbt-plugin" % "1.0.0") -addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.0-SNAPSHOT") +addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.0-M3") addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "0.9.3") addSbtPlugin("com.github.tkawachi" % "sbt-doctest" % "0.8.0") addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "2.0") From 83c1e77cb3fc2455908a0df281858bb507c3ecf5 Mon Sep 17 00:00:00 2001 From: Kailuo Wang Date: Fri, 27 Jul 2018 22:37:35 -0400 Subject: [PATCH 10/20] fix catalyst 0.7 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 7678288e51..a6fdac97ee 100644 --- a/build.sbt +++ b/build.sbt @@ -129,7 +129,7 @@ lazy val includeGeneratedSrc: Setting[_] = { // 2.13.0-M4 workarounds def catalystsVersion(scalaVersion: String): String = - if (priorTo2_13(scalaVersion)) "0.6" else "0.7-SNAPSHOT" + if (priorTo2_13(scalaVersion)) "0.6" else "0.7" def scalatestVersion(scalaVersion: String): String = if (priorTo2_13(scalaVersion)) "3.0.5" else "3.0.6-SNAP1" From 3173a20a61ea312a4bc3fef19fa40ab6aa0da271 Mon Sep 17 00:00:00 2001 From: Kailuo Wang Date: Sat, 28 Jul 2018 08:11:05 -0400 Subject: [PATCH 11/20] fix format --- core/src/main/scala/cats/data/NonEmptySet.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/scala/cats/data/NonEmptySet.scala b/core/src/main/scala/cats/data/NonEmptySet.scala index 7b201e5f12..cf39299c12 100644 --- a/core/src/main/scala/cats/data/NonEmptySet.scala +++ b/core/src/main/scala/cats/data/NonEmptySet.scala @@ -349,7 +349,7 @@ sealed class NonEmptySetOps[A](val value: NonEmptySet[A]) { /** * Zips this `NonEmptySet` with its index. */ - def zipWithIndex: NonEmptySet[(A, Int)] ={ + def zipWithIndex: NonEmptySet[(A, Int)] = { NonEmptySetImpl.create(cats.compat.SortedSet.zipWithIndex(toSortedSet)) } From 481f43152953ef103ddc6cc84c01fc1febadf3ad Mon Sep 17 00:00:00 2001 From: Kailuo Wang Date: Sat, 28 Jul 2018 09:31:23 -0400 Subject: [PATCH 12/20] fix bc with exception --- build.sbt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index a6fdac97ee..1f066ea513 100644 --- a/build.sbt +++ b/build.sbt @@ -266,7 +266,8 @@ def mimaSettings(moduleName: String) = { exclude[DirectMissingMethodProblem]("cats.data.KleisliInstances0.catsDataMonadForKleisliId"), exclude[DirectMissingMethodProblem]("cats.data.KleisliInstances1.catsDataCommutativeArrowForKleisli"), exclude[DirectMissingMethodProblem]("cats.data.KleisliInstances4.catsDataCommutativeFlatMapForKleisli"), - exclude[DirectMissingMethodProblem]("cats.data.IRWSTInstances1.catsDataStrongForIRWST") + exclude[DirectMissingMethodProblem]("cats.data.IRWSTInstances1.catsDataStrongForIRWST"), + exclude[DirectMissingMethodProblem]("cats.data.OptionTInstances1.catsDataMonadErrorMonadForOptionT") ) } ) From 42ae55e2c1354d360b1ae36c0da57922dee9f5b3 Mon Sep 17 00:00:00 2001 From: Kailuo Wang Date: Sat, 28 Jul 2018 15:03:56 -0400 Subject: [PATCH 13/20] ignore tut for now on 2.13 --- .jvmopts | 2 +- scripts/travis-publish.sh | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.jvmopts b/.jvmopts index 481b1cbd58..262ea9e03f 100644 --- a/.jvmopts +++ b/.jvmopts @@ -1,7 +1,7 @@ -Dfile.encoding=UTF8 -Xms1G -Xmx6G --XX:MaxMetaspaceSize=2G +-XX:MaxMetaspaceSize=4G -XX:ReservedCodeCacheSize=250M -XX:+TieredCompilation -XX:-UseGCOverheadLimit diff --git a/scripts/travis-publish.sh b/scripts/travis-publish.sh index 768bcd91b2..b4936174e9 100755 --- a/scripts/travis-publish.sh +++ b/scripts/travis-publish.sh @@ -36,7 +36,15 @@ kernel_js="$sbt_cmd validateKernelJS" free_js="$sbt_cmd validateFreeJS" js="$core_js && $free_js && $kernel_js" + +# Skip coverage and docs on 2.13 for now. +if [[ $TRAVIS_SCALA_VERSION == *"2.13"* ]]; then +jvm="$sbt_cmd buildJVM" +else jvm="$sbt_cmd coverage validateJVM coverageReport && codecov" +fi + + if [[ $TRAVIS_SCALA_VERSION == *"2.12"* ]]; then scalafix="sbt ';coreJVM/publishLocal;freeJVM/publishLocal' && cd scalafix && sbt tests/test && cd .. &&" From e6ae9855a2d249bf8caf4dc938deb661188a4c04 Mon Sep 17 00:00:00 2001 From: Kailuo Wang Date: Sat, 28 Jul 2018 20:27:16 -0400 Subject: [PATCH 14/20] fixing build --- scripts/travis-publish.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/travis-publish.sh b/scripts/travis-publish.sh index b4936174e9..33c05b1c50 100755 --- a/scripts/travis-publish.sh +++ b/scripts/travis-publish.sh @@ -47,7 +47,7 @@ fi if [[ $TRAVIS_SCALA_VERSION == *"2.12"* ]]; then -scalafix="sbt ';coreJVM/publishLocal;freeJVM/publishLocal' && cd scalafix && sbt tests/test && cd .. &&" +scalafix="$sbt_cmd coreJVM/publishLocal freeJVM/publishLocal && cd scalafix && $sbt_cmd tests/test && cd .. &&" else scalafix="" fi From 85f20addcc2ea4264c0cda33d14cf2cdc4f95f76 Mon Sep 17 00:00:00 2001 From: Kailuo Wang Date: Sat, 28 Jul 2018 20:54:27 -0400 Subject: [PATCH 15/20] updated scalafix version --- scalafix/project/plugins.sbt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scalafix/project/plugins.sbt b/scalafix/project/plugins.sbt index 20784f6ce3..77ac6fb07d 100644 --- a/scalafix/project/plugins.sbt +++ b/scalafix/project/plugins.sbt @@ -1,4 +1,4 @@ -addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.5.2") -addSbtPlugin("io.get-coursier" % "sbt-coursier" % "1.0.0-RC12") +addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.5.10") +addSbtPlugin("io.get-coursier" % "sbt-coursier" % "1.0.0") addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.7.0") -addSbtPlugin("org.lyranthe.sbt" % "partial-unification" % "1.1.0") +addSbtPlugin("org.lyranthe.sbt" % "partial-unification" % "1.1.2") From 82af3a799928c2f0347b33f5990e6d83c156e3b5 Mon Sep 17 00:00:00 2001 From: Kailuo Wang Date: Mon, 30 Jul 2018 11:33:00 -0400 Subject: [PATCH 16/20] fix travis build --- scripts/travis-publish.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/scripts/travis-publish.sh b/scripts/travis-publish.sh index 33c05b1c50..f191098bc2 100755 --- a/scripts/travis-publish.sh +++ b/scripts/travis-publish.sh @@ -17,17 +17,19 @@ # Example setting to use at command line for testing: # export TRAVIS_SCALA_VERSION=2.10.5;export TRAVIS_PULL_REQUEST="false";export TRAVIS_BRANCH="master" -export publish_cmd="publishLocal" + +sbt_cmd="sbt ++$TRAVIS_SCALA_VERSION" + +export publish_cmd="" if [[ $TRAVIS_PULL_REQUEST == "false" && $TRAVIS_BRANCH == "master" && $(cat version.sbt) =~ "-SNAPSHOT" ]]; then - export publish_cmd="publish gitSnapshots publish" + export publish_cmd="$sbt_cm publish gitSnapshots publish" # temporarily disable to stabilize travis #if [[ $TRAVIS_SCALA_VERSION =~ ^2\.11\. ]]; then # export publish_cmd="publishMicrosite" #fi fi -sbt_cmd="sbt ++$TRAVIS_SCALA_VERSION" export COURSIER_VERBOSITY=0 @@ -55,7 +57,7 @@ fi if [[ $JS_BUILD == "true" ]]; then run_cmd="$js" else -run_cmd="$scalafix $jvm && $sbt_cmd $publish_cmd" +run_cmd="$scalafix $jvm && $publish_cmd" fi eval $run_cmd From 8f4e863463343d9d8f2c20ad1271ef1a6061e68c Mon Sep 17 00:00:00 2001 From: Kailuo Wang Date: Mon, 30 Jul 2018 13:23:19 -0400 Subject: [PATCH 17/20] fixing travis --- scripts/travis-publish.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/travis-publish.sh b/scripts/travis-publish.sh index f191098bc2..8415f27a2b 100755 --- a/scripts/travis-publish.sh +++ b/scripts/travis-publish.sh @@ -23,7 +23,7 @@ sbt_cmd="sbt ++$TRAVIS_SCALA_VERSION" export publish_cmd="" if [[ $TRAVIS_PULL_REQUEST == "false" && $TRAVIS_BRANCH == "master" && $(cat version.sbt) =~ "-SNAPSHOT" ]]; then - export publish_cmd="$sbt_cm publish gitSnapshots publish" + export publish_cmd="$sbt_cmd publish gitSnapshots publish" # temporarily disable to stabilize travis #if [[ $TRAVIS_SCALA_VERSION =~ ^2\.11\. ]]; then # export publish_cmd="publishMicrosite" From 9656764c3893240c4bcf14630007acc4d26bbf97 Mon Sep 17 00:00:00 2001 From: Kailuo Wang Date: Mon, 30 Jul 2018 13:37:51 -0400 Subject: [PATCH 18/20] fix travis --- scripts/travis-publish.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/travis-publish.sh b/scripts/travis-publish.sh index 8415f27a2b..840b6e4629 100755 --- a/scripts/travis-publish.sh +++ b/scripts/travis-publish.sh @@ -23,7 +23,7 @@ sbt_cmd="sbt ++$TRAVIS_SCALA_VERSION" export publish_cmd="" if [[ $TRAVIS_PULL_REQUEST == "false" && $TRAVIS_BRANCH == "master" && $(cat version.sbt) =~ "-SNAPSHOT" ]]; then - export publish_cmd="$sbt_cmd publish gitSnapshots publish" + export publish_cmd="&& $sbt_cmd publish gitSnapshots publish" # temporarily disable to stabilize travis #if [[ $TRAVIS_SCALA_VERSION =~ ^2\.11\. ]]; then # export publish_cmd="publishMicrosite" @@ -57,7 +57,7 @@ fi if [[ $JS_BUILD == "true" ]]; then run_cmd="$js" else -run_cmd="$scalafix $jvm && $publish_cmd" +run_cmd="$scalafix $jvm $publish_cmd" fi eval $run_cmd From 4ab09465f673ef714af1b922bdb5f43a2956a710 Mon Sep 17 00:00:00 2001 From: Kailuo Wang Date: Mon, 30 Jul 2018 13:51:45 -0400 Subject: [PATCH 19/20] updated scalafix version --- scalafix/project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scalafix/project/plugins.sbt b/scalafix/project/plugins.sbt index 77ac6fb07d..451dfeef85 100644 --- a/scalafix/project/plugins.sbt +++ b/scalafix/project/plugins.sbt @@ -1,4 +1,4 @@ -addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.5.10") +addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.6.0-M12") addSbtPlugin("io.get-coursier" % "sbt-coursier" % "1.0.0") addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.7.0") addSbtPlugin("org.lyranthe.sbt" % "partial-unification" % "1.1.2") From 228bbe1666a232cb6dc0b56f92629881b0e14632 Mon Sep 17 00:00:00 2001 From: Kailuo Wang Date: Mon, 30 Jul 2018 15:08:45 -0400 Subject: [PATCH 20/20] fixing scalafix --- scalafix/build.sbt | 4 ++-- scalafix/project/plugins.sbt | 4 ++-- scripts/travis-publish.sh | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/scalafix/build.sbt b/scalafix/build.sbt index 830ec17d80..93ff410190 100644 --- a/scalafix/build.sbt +++ b/scalafix/build.sbt @@ -16,8 +16,8 @@ lazy val input = project.settings( lazy val output = project.settings( libraryDependencies ++= Seq( - "org.typelevel" %% "cats-core" % "1.0.0-SNAPSHOT", - "org.typelevel" %% "cats-free" % "1.0.0-SNAPSHOT" + "org.typelevel" %% "cats-core" % "1.0.0", + "org.typelevel" %% "cats-free" % "1.0.0" ), scalacOptions += "-language:higherKinds" ) diff --git a/scalafix/project/plugins.sbt b/scalafix/project/plugins.sbt index 451dfeef85..fbbe6c7f91 100644 --- a/scalafix/project/plugins.sbt +++ b/scalafix/project/plugins.sbt @@ -1,4 +1,4 @@ -addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.6.0-M12") -addSbtPlugin("io.get-coursier" % "sbt-coursier" % "1.0.0") +addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.5.2") +addSbtPlugin("io.get-coursier" % "sbt-coursier" % "1.0.2") addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.7.0") addSbtPlugin("org.lyranthe.sbt" % "partial-unification" % "1.1.2") diff --git a/scripts/travis-publish.sh b/scripts/travis-publish.sh index 840b6e4629..633c88b41d 100755 --- a/scripts/travis-publish.sh +++ b/scripts/travis-publish.sh @@ -49,7 +49,7 @@ fi if [[ $TRAVIS_SCALA_VERSION == *"2.12"* ]]; then -scalafix="$sbt_cmd coreJVM/publishLocal freeJVM/publishLocal && cd scalafix && $sbt_cmd tests/test && cd .. &&" +scalafix="cd scalafix && sbt tests/test && cd .. &&" else scalafix="" fi