Skip to content

Commit

Permalink
Merge branch 'master' into update/sbt-pgp-2.0.1-M3
Browse files Browse the repository at this point in the history
  • Loading branch information
scala-steward committed Sep 24, 2019
2 parents acc064a + 5a03320 commit 76f8d61
Show file tree
Hide file tree
Showing 47 changed files with 71 additions and 113 deletions.
14 changes: 3 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ git:
jdk:
- openjdk8

scala_version_211: &scala_version_211 2.11.12

scala_version_212: &scala_version_212 2.12.9
scala_version_213: &scala_version_213 2.13.0

Expand All @@ -34,22 +34,17 @@ jobs:
install: pip install --user codecov
script: sbt coverage buildJVM bench/test coverageReport && codecov

- &js_tests
stage: test
- stage: test
env: TEST="JS tests"
# http://austinpray.com/ops/2015/09/20/change-travis-node-version.html
install: rm -rf ~/.nvm && git clone https://github.com/creationix/nvm.git ~/.nvm && (cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`) && source ~/.nvm/nvm.sh && nvm install $TRAVIS_NODE_VERSION
script: sbt ++$TRAVIS_SCALA_VERSION! validateJS && sbt ++$TRAVIS_SCALA_VERSION! validateKernelJS && sbt ++$TRAVIS_SCALA_VERSION! validateFreeJS
scala: *scala_version_211
- <<: *js_tests
scala: *scala_version_212

- &jvm_tests
stage: test
env: TEST="JVM tests"
script: sbt ++$TRAVIS_SCALA_VERSION! buildJVM bench/test
scala: *scala_version_211
- <<: *jvm_tests
scala: *scala_version_212
- <<: *jvm_tests
scala: *scala_version_213
Expand All @@ -65,12 +60,9 @@ jobs:
env: TEST="scalafix"
script: cd scalafix && sbt tests/test

- &bincompat_check
stage: test
- stage: test
env: TEST="binary compatibility"
script: sbt ++$TRAVIS_SCALA_VERSION! validateBC
scala: *scala_version_211
- <<: *bincompat_check
scala: *scala_version_212

- stage: styling
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ By sharing the same set of type classes, instances and data types provided by Ca
* [scala-forex](https://github.com/snowplow/scala-forex): exchange rate lookups
* [scala-maxmind-ip-lookups](https://github.com/snowplow/scala-maxmind-iplookups): IP geolocation through [the Maxmind database](https://www.maxmind.com/en/home)
* [scala-referer-parser](https://github.com/snowplow-referer-parser/scala-referer-parser): referer parsing
* [scala-rl](https://github.com/sritchie/scala-rl): Functional, monadic reinforcement learning in Scala
* [scala-weather](https://github.com/snowplow/scala-weather): weather lookups
* [scanamo](https://github.com/guardian/scanamo): simpler DynamoDB access for Scala
* [seals](https://github.com/durban/seals): tools for schema evolution and language-integrated schemata
Expand Down Expand Up @@ -280,6 +281,7 @@ Here's a (non-exhaustive) list of companies that use Cats in production. Don't s
- [Codecentric](https://codecentric.de)
- [Colisweb](https://www.colisweb.com/)
- [Coya](https://coya.com/)
- [Datum Brain](https://datumbrain.com/)
- [DriveTribe](https://drivetribe.com/)
- [Dwolla](https://dwolla.com/)
- [Earnest](https://www.earnest.com)
Expand Down
4 changes: 3 additions & 1 deletion binCompatTest/src/main/scala/catsBC/MimaExceptions.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
package catsBC
import cats.InjectK
import cats.implicits._

object MimaExceptions {
Expand Down Expand Up @@ -27,6 +28,7 @@ object MimaExceptions {
true.iterateUntilM(Option(_))(identity _),
Either.catchOnly[NumberFormatException] { "foo".toInt },
(1.validNel[String], 2.validNel[String], 3.validNel[String]) mapN (_ + _ + _),
(1.asRight[String], 2.asRight[String], 3.asRight[String]) parMapN (_ + _ + _)
(1.asRight[String], 2.asRight[String], 3.asRight[String]) parMapN (_ + _ + _),
InjectK.catsReflexiveInjectKInstance[Option]
)
}
62 changes: 23 additions & 39 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ def scalaVersionSpecificFolders(srcName: String, srcBaseDir: java.io.File, scala
List(CrossType.Pure, CrossType.Full)
.flatMap(_.sharedSrcDir(srcBaseDir, srcName).toList.map(f => file(f.getPath + suffix)))
CrossVersion.partialVersion(scalaVersion) match {
case Some((2, y)) if y <= 12 =>
extraDirs("-2.12-")
case Some((2, y)) if y >= 13 =>
extraDirs("-2.13+")
case _ => Nil
Expand All @@ -65,6 +63,8 @@ lazy val commonScalaVersionSettings = Seq(

commonScalaVersionSettings

ThisBuild / mimaFailOnNoPrevious := false

lazy val commonSettings = commonScalaVersionSettings ++ Seq(
scalacOptions ++= commonScalacOptions(scalaVersion.value),
Compile / unmanagedSourceDirectories ++= scalaVersionSpecificFolders("main", baseDirectory.value, scalaVersion.value),
Expand All @@ -82,7 +82,7 @@ lazy val commonSettings = commonScalaVersionSettings ++ Seq(
val docSource = (sources in (Compile, doc)).value
if (priorTo2_13(scalaVersion.value)) docSource else Nil
}
) ++ warnUnusedImport ++ update2_12 ++ xlint
) ++ warnUnusedImport

def macroDependencies(scalaVersion: String) =
CrossVersion.partialVersion(scalaVersion) match {
Expand Down Expand Up @@ -152,11 +152,6 @@ lazy val commonJvmSettings = Seq(
Test / javaOptions := Seq("-Xmx3G")
)

lazy val commonNativeSettings = Seq(
scalaVersion := "2.11.12", // TODO: load scala version form .travis.yml: https://github.com/dwijnand/sbt-travisci/issues/11
crossScalaVersions := Seq("2.11.12")
)

lazy val includeGeneratedSrc: Setting[_] = {
mappings in (Compile, packageSrc) ++= {
val base = (sourceManaged in Compile).value
Expand Down Expand Up @@ -397,7 +392,18 @@ def mimaSettings(moduleName: String) =
exclude[IncompatibleMethTypeProblem]("cats.arrow.FunctionKMacros.lift"),
exclude[MissingTypesProblem]("cats.arrow.FunctionKMacros$"),
exclude[IncompatibleMethTypeProblem]("cats.arrow.FunctionKMacros#Lifter.this"),
exclude[IncompatibleResultTypeProblem]("cats.arrow.FunctionKMacros#Lifter.c")
exclude[IncompatibleResultTypeProblem]("cats.arrow.FunctionKMacros#Lifter.c"),
exclude[DirectMissingMethodProblem]("cats.arrow.FunctionKMacros.compatNewTypeName")
) ++ //package private classes no longer needed
Seq(
exclude[MissingClassProblem]("cats.kernel.compat.scalaVersionMoreSpecific$"),
exclude[MissingClassProblem]("cats.kernel.compat.scalaVersionMoreSpecific"),
exclude[MissingClassProblem](
"cats.kernel.compat.scalaVersionMoreSpecific$suppressUnusedImportWarningForScalaVersionMoreSpecific"
)
) ++ // Only narrowing of types allowed here
Seq(
exclude[IncompatibleSignatureProblem]("*")
)
}
)
Expand Down Expand Up @@ -651,9 +657,12 @@ lazy val bench = project
.enablePlugins(JmhPlugin)

lazy val binCompatTest = project
.disablePlugins(CoursierPlugin)
.settings(noPublishSettings)
.settings(
// workaround because coursier doesn't understand dependsOn(core.jvm % Test)
// see https://github.com/typelevel/cats/pull/3079#discussion_r327181584
// see https://github.com/typelevel/cats/pull/3026#discussion_r321984342
useCoursier := false,
commonScalaVersionSettings,
addCompilerPlugin("org.typelevel" %% "kind-projector" % kindProjectorVersion),
libraryDependencies ++= List(
Expand Down Expand Up @@ -788,7 +797,7 @@ addCommandAlias("validateKernelJS", "kernelLawsJS/test")
addCommandAlias("validateFreeJS", "freeJS/test") //separated due to memory constraint on travis
addCommandAlias("validate", ";clean;validateJS;validateKernelJS;validateFreeJS;validateJVM")

addCommandAlias("prePR", ";fmt;++2.11.12 mimaReportBinaryIssues")
addCommandAlias("prePR", "fmt")

////////////////////////////////////////////////////////////////////////////////////////////////////
// Base Build Settings - Should not need to edit below this line.
Expand Down Expand Up @@ -827,7 +836,8 @@ def commonScalacOptions(scalaVersion: String) =
"-Ywarn-numeric-widen",
"-Ywarn-value-discard",
"-Xfatal-warnings",
"-deprecation"
"-deprecation",
"-Xlint:-unused,_"
) ++ (if (priorTo2_13(scalaVersion))
Seq(
"-Yno-adapted-args",
Expand Down Expand Up @@ -878,15 +888,7 @@ lazy val sharedReleaseProcess = Seq(
)

lazy val warnUnusedImport = Seq(
scalacOptions ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 11)) =>
Seq("-Ywarn-unused-import")
case Some((2, n)) if n >= 12 =>
Seq("-Ywarn-unused:imports")

}
},
scalacOptions ++= Seq("-Ywarn-unused:imports"),
scalacOptions in (Compile, console) ~= { _.filterNot(Set("-Ywarn-unused-import", "-Ywarn-unused:imports")) },
scalacOptions in (Test, console) := (scalacOptions in (Compile, console)).value
)
Expand All @@ -898,21 +900,3 @@ lazy val credentialSettings = Seq(
password <- Option(System.getenv().get("SONATYPE_PASSWORD"))
} yield Credentials("Sonatype Nexus Repository Manager", "oss.sonatype.org", username, password)).toSeq
)

lazy val update2_12 = Seq(
scalacOptions -= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, scalaMajor)) if scalaMajor >= 12 => "-Yinline-warnings"
case _ => ""
}
}
)

lazy val xlint = Seq(
scalacOptions += {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, scalaMajor)) if scalaMajor >= 12 => "-Xlint:-unused,_"
case _ => "-Xlint"
}
}
)
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ trait ParallelInstances extends ParallelInstances1 {
}

@deprecated("Use OptionT.catsDataParallelForOptionT", "2.0.0")
private[instances] def catsParallelForOptionTNestedOption[M[_]](
def catsParallelForOptionTNestedOption[M[_]](
implicit P: Parallel[M]
): Parallel.Aux[OptionT[M, *], Nested[P.F, Option, *]] = OptionT.catsDataParallelForOptionT[M]

Expand Down Expand Up @@ -69,7 +69,7 @@ trait ParallelInstances extends ParallelInstances1 {
}

@deprecated("Use EitherT.catsDataParallelForEitherTWithParallelEffect", "2.0.0")
private[instances] def catsParallelForEitherTNestedParallelValidated[M[_], E: Semigroup](
def catsParallelForEitherTNestedParallelValidated[M[_], E: Semigroup](
implicit P: Parallel[M]
): Parallel.Aux[EitherT[M, E, *], Nested[P.F, Validated[E, *], *]] =
EitherT.catsDataParallelForEitherTWithParallelEffect[M, E]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ trait ParallelInstances extends ParallelInstances1 {
}

@deprecated("Use OptionT.catsDataParallelForOptionT", "2.0.0")
private[instances] def catsParallelForOptionTNestedOption[M[_]](
def catsParallelForOptionTNestedOption[M[_]](
implicit P: Parallel[M]
): Parallel.Aux[OptionT[M, *], Nested[P.F, Option, *]] = OptionT.catsDataParallelForOptionT[M]

Expand Down Expand Up @@ -84,7 +84,7 @@ trait ParallelInstances extends ParallelInstances1 {
}

@deprecated("Use EitherT.catsDataParallelForEitherTWithParallelEffect", "2.0.0")
private[instances] def catsParallelForEitherTNestedParallelValidated[M[_], E: Semigroup](
def catsParallelForEitherTNestedParallelValidated[M[_], E: Semigroup](
implicit P: Parallel[M]
): Parallel.Aux[EitherT[M, E, *], Nested[P.F, Validated[E, *], *]] =
EitherT.catsDataParallelForEitherTWithParallelEffect[M, E]
Expand Down
3 changes: 0 additions & 3 deletions core/src/main/scala/cats/Inject.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package cats

import kernel.compat.scalaVersionMoreSpecific._

/**
* Inject is a type class providing an injection from type `A` into
* type `B`. An injection is a function `inj` which does not destroy
Expand All @@ -27,7 +25,6 @@ abstract class Inject[A, B] {
final def unapply(b: B): Option[A] = prj(b)
}

@suppressUnusedImportWarningForScalaVersionMoreSpecific
sealed abstract private[cats] class InjectInstances {
implicit def catsReflexiveInjectInstance[A]: Inject[A, A] =
new Inject[A, A] {
Expand Down
2 changes: 0 additions & 2 deletions core/src/main/scala/cats/InjectK.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package cats

import cats.arrow.FunctionK
import cats.data.EitherK
import kernel.compat.scalaVersionMoreSpecific._

/**
* InjectK is a type class providing an injection from type
Expand Down Expand Up @@ -33,7 +32,6 @@ abstract class InjectK[F[_], G[_]] {
final def unapply[A](ga: G[A]): Option[F[A]] = prj(ga)
}

@suppressUnusedImportWarningForScalaVersionMoreSpecific
sealed abstract private[cats] class InjectKInstances {
implicit def catsReflexiveInjectKInstance[F[_]]: InjectK[F, F] =
new InjectK[F, F] {
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/data/Op.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ sealed abstract private[data] class OpInstances extends OpInstances0 {
new OpEq[Arr, A, B] { def Arr: Eq[Arr[B, A]] = ArrEq }

@deprecated("Use catsDataEqForOp", "2.0.0-RC2")
private[data] def catsKernelEqForOp[Arr[_, _], A, B](implicit ArrEq: Eq[Arr[B, A]]): Eq[Op[Arr, A, B]] =
def catsKernelEqForOp[Arr[_, _], A, B](implicit ArrEq: Eq[Arr[B, A]]): Eq[Op[Arr, A, B]] =
catsDataEqForOp[Arr, A, B]
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/instances/parallel.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import cats.{~>, Applicative, Monad, Parallel}

private[instances] trait ParallelInstances1 {
@deprecated("Use EitherT.catsDataParallelForEitherTWithSequentialEffect", "2.0.0")
private[instances] def catsParallelForEitherTNestedValidated[M[_]: Monad, E: Semigroup]
def catsParallelForEitherTNestedValidated[M[_]: Monad, E: Semigroup]
: Parallel.Aux[EitherT[M, E, *], Nested[M, Validated[E, *], *]] =
new Parallel[EitherT[M, E, *]] {
type F[x] = Nested[M, Validated[E, *], x]
Expand Down
8 changes: 4 additions & 4 deletions core/src/main/scala/cats/instances/sortedMap.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import scala.collection.immutable.SortedMap
trait SortedMapInstances extends SortedMapInstances2 {

@deprecated("2.0.0-RC2", "Use cats.kernel.instances.sortedMap.catsKernelStdHashForSortedMap")
private[instances] def catsStdHashForSortedMap[K: Hash: Order, V: Hash]: Hash[SortedMap[K, V]] =
def catsStdHashForSortedMap[K: Hash: Order, V: Hash]: Hash[SortedMap[K, V]] =
cats.kernel.instances.sortedMap.catsKernelStdHashForSortedMap[K, V]

@deprecated("2.0.0-RC2", "Use cats.kernel.instances.sortedMap.catsKernelStdCommutativeMonoidForSortedMap")
private[instances] def catsStdCommutativeMonoidForSortedMap[K: Order, V: CommutativeSemigroup] =
def catsStdCommutativeMonoidForSortedMap[K: Order, V: CommutativeSemigroup] =
cats.kernel.instances.sortedMap.catsKernelStdCommutativeMonoidForSortedMap[K, V]

implicit def catsStdShowForSortedMap[A: Order, B](implicit showA: Show[A], showB: Show[B]): Show[SortedMap[A, B]] =
Expand Down Expand Up @@ -115,13 +115,13 @@ trait SortedMapInstances extends SortedMapInstances2 {

private[instances] trait SortedMapInstances1 {
@deprecated("2.0.0-RC2", "Use cats.kernel.instances.sortedMap.catsKernelStdEqForSortedMap")
private[instances] def catsStdEqForSortedMap[K: Order, V: Eq]: Eq[SortedMap[K, V]] =
def catsStdEqForSortedMap[K: Order, V: Eq]: Eq[SortedMap[K, V]] =
new SortedMapEq[K, V]
}

private[instances] trait SortedMapInstances2 extends SortedMapInstances1 {
@deprecated("2.0.0-RC2", "Use cats.kernel.instances.sortedMap.catsKernelStdMonoidForSortedMap")
private[instances] def catsStdMonoidForSortedMap[K: Order, V: Semigroup]: Monoid[SortedMap[K, V]] =
def catsStdMonoidForSortedMap[K: Order, V: Semigroup]: Monoid[SortedMap[K, V]] =
new SortedMapMonoid[K, V]
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/instances/sortedSet.scala
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ private[instances] trait SortedSetInstances1 {
cats.kernel.instances.sortedSet.catsKernelStdHashForSortedSet[A]

@deprecated("2.0.0-RC2", "Use cats.kernel.instances.sortedSet.catsKernelStdSemilatticeForSortedSet")
private[instances] def catsKernelStdSemilatticeForSortedSet[A: Order]: BoundedSemilattice[SortedSet[A]] =
def catsKernelStdSemilatticeForSortedSet[A: Order]: BoundedSemilattice[SortedSet[A]] =
cats.kernel.instances.sortedSet.catsKernelStdBoundedSemilatticeForSortedSet[A]
}

Expand Down
2 changes: 1 addition & 1 deletion docs/src/main/tut/typeclasses/comonad.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ scaladoc: "#cats.Comonad"

`Comonad` is a `Functor` and provides duals of the [`Monad`](monad.html) `pure`
and `flatMap` functions. A dual to a function has the same types but the
direction of the arrows are reversed. Whether or not that is useful even possible
direction of the arrows are reversed. Whether or not that is useful, or even possible,
depends on the particular type. For a more formal definition of duality, please
refer to [https://ncatlab.org/nlab/show/duality](https://ncatlab.org/nlab/show/duality).

Expand Down
12 changes: 6 additions & 6 deletions docs/src/main/tut/typeclasses/lawtesting.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ object arbitraries {
Now we can convert these `ScalaCheck` `Properties` into tests that the test framework can run. [discipline](https://github.com/typelevel/discipline) provides a helper `checkAll` function that performs
this conversion for two test frameworks: `ScalaTest` and `Specs2`.

* If you are using `Specs2`, extend your test class with `org.typelevel.discipline.specs2.Discipline`.
* If you are using `Specs2`, extend your test class with `org.typelevel.discipline.specs2.Discipline` (provided by `discipline-specs2`).

* If you are using `ScalaTest`, extend your test class with `org.typelevel.discipline.scalatest.Discipline` and `org.scalatest.funsuite.AnyFunSuiteLike`.
* If you are using `ScalaTest`, extend your test class with `org.typelevel.discipline.scalatest.Discipline` (provided by `discipline-scalatest`) and `org.scalatest.funsuite.AnyFunSuiteLike`.

* For other test frameworks, you need to resort to their integration with `ScalaCheck` to test
the `ScalaCheck` `Properties` provided by cats-laws.
the `ScalaCheck` `Properties` provided by `cats-laws`.

The following example is for ScalaTest. If not using
The following example is for ScalaTest.

```tut:book
import cats.implicits._
Expand All @@ -109,8 +109,8 @@ class TreeLawTests extends AnyFunSuite with Discipline {
* `Discipline` provides `checkAll`, and must be mixed into `AnyFunSuite`
* `arbitraries._` imports the `Arbitrary[Tree[_]]` instances needed to check the laws.

Alternatively, you can use the `CatsSuite` provided by [Cats-testkit-scalatest](https://github.com/typelevel/cats-testkit-scalatest),
which is the same `CatsSuite` used in Cats to test all instances.
Alternatively, you can use the `CatsSuite` provided by [Cats-testkit-scalatest](https://github.com/typelevel/cats-testkit-scalatest),
which is the same `CatsSuite` used in Cats to test all instances.

Now when we run `test` in our sbt console, ScalaCheck will test if the `Functor` laws hold for our `Tree` type.
You should see something like this:
Expand Down
2 changes: 1 addition & 1 deletion docs/src/main/tut/typeclasses/semigroup.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ for `Map`s.
```tut:book:silent
import cats.implicits._
val map1 = Map("hello" -> 0, "world" -> 1)
val map1 = Map("hello" -> 1, "world" -> 1)
val map2 = Map("hello" -> 2, "cats" -> 3)
```

Expand Down
2 changes: 2 additions & 0 deletions docs/src/main/tut/typeclasses/traverse.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ def foldMap[F[_]: Traverse, A, B: Monoid](fa: F[A])(f: A => B): B =
Traverse[F].traverse[Const[B, *], A, B](fa)(a => Const(f(a))).getConst
```

This works because `Const[B, *]` is an `Applicative` if `B` is a `Monoid`, as explained in [the documentation of `Const`](const.html#example-2-traverse).

## Further Reading

* [The Essence of the Iterator Pattern][iterator] - Gibbons, Oliveira. JFP 2009.
Expand Down
Loading

0 comments on commit 76f8d61

Please sign in to comment.