Skip to content

Commit

Permalink
Merge branch 'master' into enable-coverage-and-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
DieBauer committed Oct 11, 2019
2 parents 3e4d184 + ca591fc commit 3f98b90
Show file tree
Hide file tree
Showing 22 changed files with 967 additions and 159 deletions.
9 changes: 6 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jdk:
- openjdk8


scala_version_212: &scala_version_212 2.12.9
scala_version_212: &scala_version_212 2.12.10
scala_version_213: &scala_version_213 2.13.0

before_install:
Expand All @@ -29,12 +29,15 @@ stages:
jobs:
include:
# it can speed up the overall build to have the longer-running jobs at the top of this list.
- stage: test
- &js_tests
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_212
- <<: *js_tests
scala: *scala_version_213

- &jvm_tests
stage: test
Expand Down Expand Up @@ -64,7 +67,7 @@ jobs:

- stage: styling
env: TEST="linting"
script: sbt fmtCheck
script: sbt +fmtCheck

- stage: publish snapshot
script: |
Expand Down
40 changes: 13 additions & 27 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,15 @@ val isTravisBuild = settingKey[Boolean]("Flag indicating whether the current bui
val crossScalaVersionsFromTravis = settingKey[Seq[String]]("Scala versions set in .travis.yml as scala_version_XXX")
isTravisBuild in Global := sys.env.get("TRAVIS").isDefined

val scalatestVersion = "3.1.0-SNAP13"

val scalatestplusScalaCheckVersion = "1.0.0-SNAP8"

val scalaCheckVersion = "1.14.2"

val disciplineVersion = "1.0.0"
val scalatestplusScalaCheckVersion = "3.1.0.0-RC2"

val disciplineScalatestVersion = "1.0.0-M1"
val disciplineVersion = "1.0.1"

val kindProjectorVersion = "0.10.3"
val disciplineScalatestVersion = "1.0.0-RC1"

val kindProjectorVersion = "0.11.0"

crossScalaVersionsFromTravis in Global := {
val manifest = (baseDirectory in ThisBuild).value / ".travis.yml"
Expand Down Expand Up @@ -85,7 +83,7 @@ def macroDependencies(scalaVersion: String) =
lazy val catsSettings = Seq(
incOptions := incOptions.value.withLogRecompileOnMacro(false),
libraryDependencies ++= Seq(
compilerPlugin("org.typelevel" %% "kind-projector" % kindProjectorVersion)
compilerPlugin(("org.typelevel" %% "kind-projector" % kindProjectorVersion).cross(CrossVersion.full))
) ++ macroDependencies(scalaVersion.value)
) ++ commonSettings ++ publishSettings ++ scoverageSettings ++ simulacrumSettings

Expand All @@ -99,7 +97,7 @@ lazy val simulacrumSettings = Seq(
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 == "groupId" && child.text == "org.typelevel") &&
e.child.exists(child => child.label == "artifactId" && child.text.startsWith("simulacrum_")) =>
Nil
case _ => Seq(node)
Expand Down Expand Up @@ -157,9 +155,8 @@ lazy val disciplineDependencies = Seq(

lazy val testingDependencies = Seq(
libraryDependencies ++= Seq(
"org.scalatest" %%% "scalatest" % scalatestVersion % "test",
"org.scalatestplus" %%% "scalatestplus-scalacheck" % scalatestplusScalaCheckVersion % "test",
"org.typelevel" %%% "discipline-scalatest" % disciplineScalatestVersion % "test"
"org.typelevel" %%% "discipline-scalatest" % disciplineScalatestVersion % "test",
"org.scalatestplus" %%% "scalatestplus-scalacheck" % scalatestplusScalaCheckVersion % "test"
)
)

Expand Down Expand Up @@ -560,12 +557,7 @@ lazy val tests = crossProject(JSPlatform, JVMPlatform)
.settings(moduleName := "cats-tests")
.settings(catsSettings)
.settings(noPublishSettings)
.settings(
libraryDependencies ++= Seq(
"org.scalatestplus" %%% "scalatestplus-scalacheck" % scalatestplusScalaCheckVersion,
"org.typelevel" %%% "discipline-scalatest" % disciplineScalatestVersion
)
)
.settings(testingDependencies)
.jsSettings(commonJsSettings)
.jvmSettings(commonJvmSettings)
.settings(scalacOptions in Test := (scalacOptions in Test).value.filter(_ != "-Xfatal-warnings"))
Expand All @@ -578,11 +570,6 @@ lazy val testkit = crossProject(JSPlatform, JVMPlatform)
.settings(moduleName := "cats-testkit")
.settings(catsSettings)
.settings(disciplineDependencies)
.settings(
libraryDependencies ++= Seq(
"org.scalacheck" %%% "scalacheck" % scalaCheckVersion
)
)
.jsSettings(commonJsSettings)
.jvmSettings(commonJvmSettings)
.settings(scalacOptions := scalacOptions.value.filter(_ != "-Xfatal-warnings"))
Expand Down Expand Up @@ -653,17 +640,17 @@ lazy val binCompatTest = project
// see https://github.com/typelevel/cats/pull/3026#discussion_r321984342
useCoursier := false,
commonScalaVersionSettings,
addCompilerPlugin("org.typelevel" %% "kind-projector" % kindProjectorVersion),
addCompilerPlugin(("org.typelevel" %% "kind-projector" % kindProjectorVersion).cross(CrossVersion.full)),
libraryDependencies ++= List(
{
if (priorTo2_13(scalaVersion.value))
mimaPrevious("cats-core", scalaVersion.value, version.value).last % Provided
else //We are not testing BC on Scala 2.13 yet.
"org.typelevel" %% "cats-core" % "2.0.0-M4" % Provided
},
"org.scalatest" %%% "scalatest" % scalatestVersion % Test
}
)
)
.settings(testingDependencies)
.dependsOn(core.jvm % Test)

// cats-js is JS-only
Expand Down Expand Up @@ -846,7 +833,6 @@ def priorTo2_13(scalaVersion: String): Boolean =
lazy val sharedPublishSettings = Seq(
releaseTagName := tagName.value,
releaseVcsSign := true,
useGpg := true, // bouncycastle has bugs with subkeys, so we use gpg instead
publishMavenStyle := true,
publishArtifact in Test := false,
pomIncludeRepository := Function.const(false),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,70 +3,30 @@ package instances

import cats.data._
import cats.kernel.Semigroup
import cats.syntax.either._
import cats.{~>, Applicative, Apply, FlatMap, Monad, NonEmptyParallel, Parallel}
import cats.{NonEmptyParallel, Parallel}

trait ParallelInstances extends ParallelInstances1 {
implicit def catsParallelForEitherValidated[E: Semigroup]: Parallel.Aux[Either[E, *], Validated[E, *]] =
new Parallel[Either[E, *]] {
type F[x] = Validated[E, x]

def applicative: Applicative[Validated[E, *]] = Validated.catsDataApplicativeErrorForValidated
def monad: Monad[Either[E, *]] = cats.instances.either.catsStdInstancesForEither

def sequential: Validated[E, *] ~> Either[E, *] =
λ[Validated[E, *] ~> Either[E, *]](_.toEither)

def parallel: Either[E, *] ~> Validated[E, *] =
λ[Either[E, *] ~> Validated[E, *]](_.toValidated)
}
@deprecated("Use cats.instances.either.catsParallelForEitherAndValidated", "2.1.0")
def catsParallelForEitherValidated[E: Semigroup]: Parallel.Aux[Either[E, *], Validated[E, *]] =
cats.instances.either.catsParallelForEitherAndValidated[E]

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

implicit def catsStdNonEmptyParallelForZipList: NonEmptyParallel.Aux[List, ZipList] =
new NonEmptyParallel[List] {
type F[x] = ZipList[x]

def flatMap: FlatMap[List] = cats.instances.list.catsStdInstancesForList
def apply: Apply[ZipList] = ZipList.catsDataCommutativeApplyForZipList

def sequential: ZipList ~> List =
λ[ZipList ~> List](_.value)

def parallel: List ~> ZipList =
λ[List ~> ZipList](v => new ZipList(v))
}

implicit def catsStdNonEmptyParallelForZipVector: NonEmptyParallel.Aux[Vector, ZipVector] =
new NonEmptyParallel[Vector] {
type F[x] = ZipVector[x]

def flatMap: FlatMap[Vector] = cats.instances.vector.catsStdInstancesForVector
def apply: Apply[ZipVector] = ZipVector.catsDataCommutativeApplyForZipVector

def sequential: ZipVector ~> Vector =
λ[ZipVector ~> Vector](_.value)

def parallel: Vector ~> ZipVector =
λ[Vector ~> ZipVector](v => new ZipVector(v))
}

implicit def catsStdParallelForZipStream: Parallel.Aux[Stream, ZipStream] =
new Parallel[Stream] {
type F[x] = ZipStream[x]

def monad: Monad[Stream] = cats.instances.stream.catsStdInstancesForStream
def applicative: Applicative[ZipStream] = ZipStream.catsDataAlternativeForZipStream
@deprecated("Use cats.instances.list.catsStdNonEmptyParallelForListZipList", "2.1.0")
def catsStdNonEmptyParallelForZipList: NonEmptyParallel.Aux[List, ZipList] =
cats.instances.list.catsStdNonEmptyParallelForListZipList

def sequential: ZipStream ~> Stream =
λ[ZipStream ~> Stream](_.value)
@deprecated("Use cats.instances.vector.catsStdNonEmptyParallelForVectorZipVector", "2.1.0")
def catsStdNonEmptyParallelForZipVector: NonEmptyParallel.Aux[Vector, ZipVector] =
cats.instances.vector.catsStdNonEmptyParallelForVectorZipVector

def parallel: Stream ~> ZipStream =
λ[Stream ~> ZipStream](v => new ZipStream(v))
}
@deprecated("Use cats.instances.stream.catsStdParallelForStreamZipStream", "2.1.0")
def catsStdParallelForZipStream: Parallel.Aux[Stream, ZipStream] =
cats.instances.stream.catsStdParallelForStreamZipStream

@deprecated("Use EitherT.catsDataParallelForEitherTWithParallelEffect", "2.0.0")
def catsParallelForEitherTNestedParallelValidated[M[_], E: Semigroup](
Expand Down
14 changes: 14 additions & 0 deletions core/src/main/scala-2.12/cats/instances/stream.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cats
package instances

import cats.data.ZipStream
import cats.syntax.show._

import scala.annotation.tailrec
Expand Down Expand Up @@ -157,6 +158,19 @@ trait StreamInstances extends cats.kernel.instances.StreamInstances {
def show(fa: Stream[A]): String = if (fa.isEmpty) "Stream()" else s"Stream(${fa.head.show}, ?)"
}

implicit def catsStdParallelForStreamZipStream: Parallel.Aux[Stream, ZipStream] =
new Parallel[Stream] {
type F[x] = ZipStream[x]

def monad: Monad[Stream] = cats.instances.stream.catsStdInstancesForStream
def applicative: Applicative[ZipStream] = ZipStream.catsDataAlternativeForZipStream

def sequential: ZipStream ~> Stream =
λ[ZipStream ~> Stream](_.value)

def parallel: Stream ~> ZipStream =
λ[Stream ~> ZipStream](v => new ZipStream(v))
}
}

private[instances] trait StreamInstancesBinCompat0 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,85 +3,35 @@ package instances

import cats.data._
import cats.kernel.Semigroup
import cats.syntax.either._
import cats.{~>, Applicative, Apply, FlatMap, Monad, NonEmptyParallel, Parallel}
import cats.data.ZipLazyList
import cats.{NonEmptyParallel, Parallel}

trait ParallelInstances extends ParallelInstances1 {
implicit def catsParallelForEitherValidated[E: Semigroup]: Parallel.Aux[Either[E, *], Validated[E, *]] =
new Parallel[Either[E, *]] {
type F[x] = Validated[E, x]

def applicative: Applicative[Validated[E, *]] = Validated.catsDataApplicativeErrorForValidated
def monad: Monad[Either[E, *]] = cats.instances.either.catsStdInstancesForEither

def sequential: Validated[E, *] ~> Either[E, *] =
λ[Validated[E, *] ~> Either[E, *]](_.toEither)

def parallel: Either[E, *] ~> Validated[E, *] =
λ[Either[E, *] ~> Validated[E, *]](_.toValidated)
}
@deprecated("Use cats.instances.either.catsParallelForEitherAndValidated", "2.1.0")
def catsParallelForEitherValidated[E: Semigroup]: Parallel.Aux[Either[E, *], Validated[E, *]] =
cats.instances.either.catsParallelForEitherAndValidated[E]

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

implicit def catsStdNonEmptyParallelForZipList: NonEmptyParallel.Aux[List, ZipList] =
new NonEmptyParallel[List] {
type F[x] = ZipList[x]

def flatMap: FlatMap[List] = cats.instances.list.catsStdInstancesForList
def apply: Apply[ZipList] = ZipList.catsDataCommutativeApplyForZipList

def sequential: ZipList ~> List =
λ[ZipList ~> List](_.value)

def parallel: List ~> ZipList =
λ[List ~> ZipList](v => new ZipList(v))
}

implicit def catsStdNonEmptyParallelForZipVector: NonEmptyParallel.Aux[Vector, ZipVector] =
new NonEmptyParallel[Vector] {
type F[x] = ZipVector[x]

def flatMap: FlatMap[Vector] = cats.instances.vector.catsStdInstancesForVector
def apply: Apply[ZipVector] = ZipVector.catsDataCommutativeApplyForZipVector
@deprecated("Use cats.instances.list.catsStdNonEmptyParallelForListZipList", "2.1.0")
def catsStdNonEmptyParallelForZipList: NonEmptyParallel.Aux[List, ZipList] =
cats.instances.list.catsStdNonEmptyParallelForListZipList

def sequential: ZipVector ~> Vector =
λ[ZipVector ~> Vector](_.value)

def parallel: Vector ~> ZipVector =
λ[Vector ~> ZipVector](v => new ZipVector(v))
}
@deprecated("Use cats.instances.vector.catsStdNonEmptyParallelForVectorZipVector", "2.1.0")
def catsStdNonEmptyParallelForZipVector: NonEmptyParallel.Aux[Vector, ZipVector] =
cats.instances.vector.catsStdNonEmptyParallelForVectorZipVector

@deprecated("Use catsStdParallelForZipLazyList", "2.0.0-RC2")
implicit def catsStdParallelForZipStream: Parallel.Aux[Stream, ZipStream] =
new Parallel[Stream] {
type F[x] = ZipStream[x]

def monad: Monad[Stream] = cats.instances.stream.catsStdInstancesForStream
def applicative: Applicative[ZipStream] = ZipStream.catsDataAlternativeForZipStream

def sequential: ZipStream ~> Stream =
λ[ZipStream ~> Stream](_.value)

def parallel: Stream ~> ZipStream =
λ[Stream ~> ZipStream](v => new ZipStream(v))
}

implicit def catsStdParallelForZipLazyList[A]: Parallel.Aux[LazyList, ZipLazyList] =
new Parallel[LazyList] {
type F[x] = ZipLazyList[x]

def monad: Monad[LazyList] = cats.instances.lazyList.catsStdInstancesForLazyList
def applicative: Applicative[ZipLazyList] = ZipLazyList.catsDataAlternativeForZipLazyList

def sequential: ZipLazyList ~> LazyList =
λ[ZipLazyList ~> LazyList](_.value)
def catsStdParallelForZipStream: Parallel.Aux[Stream, ZipStream] =
cats.instances.stream.catsStdParallelForStreamZipStream

def parallel: LazyList ~> ZipLazyList =
λ[LazyList ~> ZipLazyList](v => new ZipLazyList(v))
}
@deprecated("Use cats.instances.lazyList.catsStdParallelForLazyListZipLazyList", "2.1.0")
def catsStdParallelForZipLazyList[A]: Parallel.Aux[LazyList, ZipLazyList] =
cats.instances.lazyList.catsStdParallelForLazyListZipLazyList[A]

@deprecated("Use EitherT.catsDataParallelForEitherTWithParallelEffect", "2.0.0")
def catsParallelForEitherTNestedParallelValidated[M[_], E: Semigroup](
Expand Down
16 changes: 16 additions & 0 deletions core/src/main/scala-2.13+/cats/instances/lazyList.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package cats
package instances

import cats.kernel
import cats.syntax.show._
import cats.data.ZipLazyList

import scala.annotation.tailrec

Expand Down Expand Up @@ -155,4 +157,18 @@ trait LazyListInstances extends cats.kernel.instances.LazyListInstances {
.value

}

implicit def catsStdParallelForLazyListZipLazyList[A]: Parallel.Aux[LazyList, ZipLazyList] =
new Parallel[LazyList] {
type F[x] = ZipLazyList[x]

def monad: Monad[LazyList] = cats.instances.lazyList.catsStdInstancesForLazyList
def applicative: Applicative[ZipLazyList] = ZipLazyList.catsDataAlternativeForZipLazyList

def sequential: ZipLazyList ~> LazyList =
λ[ZipLazyList ~> LazyList](_.value)

def parallel: LazyList ~> ZipLazyList =
λ[LazyList ~> ZipLazyList](v => new ZipLazyList(v))
}
}
Loading

0 comments on commit 3f98b90

Please sign in to comment.