Skip to content

Commit

Permalink
Merge pull request #4478 from armanbilge/update/sbt-typelevel-0.5.0
Browse files Browse the repository at this point in the history
Update to sbt-typelevel 0.5.0
  • Loading branch information
armanbilge authored Jul 31, 2023
2 parents 7e04753 + 34d0904 commit 512ecc2
Show file tree
Hide file tree
Showing 18 changed files with 239 additions and 323 deletions.
421 changes: 203 additions & 218 deletions .github/workflows/ci.yml

Large diffs are not rendered by default.

16 changes: 5 additions & 11 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ val munitVersion = "1.0.0-M8"

val PrimaryJava = JavaSpec.temurin("8")
val LTSJava = JavaSpec.temurin("17")
val GraalVM11 = JavaSpec.graalvm("11")
val GraalVM = JavaSpec.graalvm("17")

ThisBuild / githubWorkflowJavaVersions := Seq(PrimaryJava, LTSJava, GraalVM11)
ThisBuild / githubWorkflowJavaVersions := Seq(PrimaryJava, LTSJava, GraalVM)

val Scala212 = "2.12.18"
val Scala213 = "2.13.11"
Expand All @@ -22,7 +22,6 @@ ThisBuild / crossScalaVersions := Seq(Scala212, Scala213, Scala3)
ThisBuild / scalaVersion := Scala213

ThisBuild / tlFatalWarnings := false
ThisBuild / tlFatalWarningsInCi := false

ThisBuild / githubWorkflowAddedJobs ++= Seq(
WorkflowJob(
Expand All @@ -32,7 +31,7 @@ ThisBuild / githubWorkflowAddedJobs ++= Seq(
WorkflowStep.Run(List("cd scalafix", "sbt test"), name = Some("Scalafix tests"))
),
javas = List(PrimaryJava),
scalas = List((ThisBuild / scalaVersion).value)
scalas = Nil
)
)

Expand Down Expand Up @@ -136,7 +135,7 @@ lazy val algebra = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.crossType(CrossType.Pure)
.in(file("algebra-core"))
.dependsOn(kernel)
.settings(moduleName := "algebra", name := "Cats algebra")
.settings(moduleName := "algebra", name := "Cats algebra", scalacOptions -= "-Xsource:3")
.settings(Compile / sourceGenerators += (Compile / sourceManaged).map(AlgebraBoilerplate.gen).taskValue)
.jsSettings(commonJsSettings)
.jvmSettings(commonJvmSettings)
Expand All @@ -151,7 +150,7 @@ lazy val algebra = crossProject(JSPlatform, JVMPlatform, NativePlatform)
lazy val algebraLaws = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.in(file("algebra-laws"))
.dependsOn(kernelLaws, algebra)
.settings(moduleName := "algebra-laws", name := "Cats algebra laws")
.settings(moduleName := "algebra-laws", name := "Cats algebra laws", scalacOptions -= "-Xsource:3")
.settings(disciplineDependencies)
.settings(testingDependencies)
.jsSettings(commonJsSettings)
Expand Down Expand Up @@ -300,11 +299,6 @@ lazy val docs = project
)
)
},
tlSiteRelatedProjects := Seq(
TypelevelProject.CatsEffect,
"Mouse" -> url("https://typelevel.org/mouse"),
TypelevelProject.Discipline
),
libraryDependencies ++= Seq(
"org.typelevel" %%% "discipline-munit" % disciplineMunitVersion
)
Expand Down
27 changes: 0 additions & 27 deletions core/src/main/scala-2/src/main/scala/cats/compat/targetName.scala

This file was deleted.

26 changes: 0 additions & 26 deletions core/src/main/scala-3/src/main/scala/cats/compat/package.scala

This file was deleted.

1 change: 1 addition & 0 deletions core/src/main/scala/cats/Align.scala
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ object Align extends ScalaVersionSpecificAlignInstances {
implicit def catsAlignForSortedMap[K]: Align[SortedMap[K, *]] =
cats.instances.sortedMap.catsStdInstancesForSortedMap[K]
implicit def catsAlignForEither[A]: Align[Either[A, *]] = cats.instances.either.catsStdInstancesForEither[A]
implicit def catsAlignForId: Align[Id] = cats.catsAlignForId

private[cats] def alignWithIterator[A, B, C](fa: Iterable[A], fb: Iterable[B])(f: Ior[A, B] => C): Iterator[C] =
new Iterator[C] {
Expand Down
8 changes: 5 additions & 3 deletions core/src/main/scala/cats/Eval.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

package cats

import org.typelevel.scalaccompat.annotation.uncheckedVariance2

import scala.annotation.tailrec

/**
Expand Down Expand Up @@ -102,20 +104,20 @@ sealed abstract class Eval[+A] extends Serializable { self =>
new Eval.FlatMap[B] {
type Start = A
val start = () => c.run(s)
val run = f
val run: (Start => Eval[B]) @uncheckedVariance2 = f
}
}
case c: Eval.Defer[A] =>
new Eval.FlatMap[B] {
type Start = A
val start = c.thunk
val run = f
val run: (Start => Eval[B]) @uncheckedVariance2 = f
}
case _ =>
new Eval.FlatMap[B] {
type Start = A
val start = () => self
val run = f
val run: (Start => Eval[B]) @uncheckedVariance2 = f
}
}

Expand Down
3 changes: 2 additions & 1 deletion core/src/main/scala/cats/Invariant.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import cats.arrow.Arrow
import cats.kernel._

import cats.kernel.compat.scalaVersionSpecific._
import org.typelevel.scalaccompat.annotation.targetName3
import scala.collection.immutable.{Queue, Seq, SortedMap}
import scala.concurrent.{ExecutionContext, Future}
import scala.util.Try
Expand Down Expand Up @@ -127,7 +128,7 @@ object Invariant extends ScalaVersionSpecificInvariantInstances with InvariantIn
: Distributive[Id] with Bimonad[Id] with CommutativeMonad[Id] with NonEmptyTraverse[Id] =
cats.catsInstancesForId
@deprecated("Added for bincompat", "2.8.0")
@cats.compat.targetName("catsInstancesForId")
@targetName3("catsInstancesForId")
private[cats] def catsInstancesForIdCompat2_6_1: Comonad[Id] =
cats.catsInstancesForId
implicit def catsMonadErrorForEither[A]: MonadError[Either[A, *], A] =
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ package object cats {
override def index[A](f: Id[A]): Unit => A = (_: Unit) => f
}

implicit val catsAlignForId: Align[Id] = new Align[Id] {
val catsAlignForId: Align[Id] = new Align[Id] {
override val functor: Functor[Id] = Functor[Id]

override def align[A, B](fa: Id[A], fb: Id[B]): Id[Ior[A, B]] = Ior.both(fa, fb)
Expand Down
4 changes: 2 additions & 2 deletions docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ Please refer to the [jump start guide](jump_start_guide.md).

## What is the difference between Cats and Scalaz?

Cats and [Scalaz](https://github.com/scalaz/scalaz) have the same goal: to facilitate pure functional programming in Scala applications. However the underlying core strategy is different; Scalaz took the approach of trying to provide a single batteries-included *standard library* for FP that powers the Scala applications. Cats, on the other hand, aims to help build an [ecosystem](/cats/#ecosystem) of pure FP libraries by providing a solid and stable foundation; these libraries can have their own styles and personalities, competing with each other, while at the same time playing nice. It is through this ecosystem of FP libraries (cats included) that Scala applications can be powered with "FP awesome-ness" and beyond by picking whatever best fit their needs.
Cats and [Scalaz](https://github.com/scalaz/scalaz) have the same goal: to facilitate pure functional programming in Scala applications. However the underlying core strategy is different; Scalaz took the approach of trying to provide a single batteries-included *standard library* for FP that powers the Scala applications. Cats, on the other hand, aims to help build an [ecosystem](typelevelEcosystem.md) of pure FP libraries by providing a solid and stable foundation; these libraries can have their own styles and personalities, competing with each other, while at the same time playing nice. It is through this ecosystem of FP libraries (cats included) that Scala applications can be powered with "FP awesome-ness" and beyond by picking whatever best fit their needs.

Based on this core strategy, Cats takes a [modular](/cats/motivations#modularity) approach and focuses on providing core, [binary compatible](/cats/#binary-compatibility-and-versioning), [approachable](/cats/motivations#approachability) and [efficient](/cats/motivations#efficiency) abstractions. It provides a welcoming and supportive environment for the [user community](https://discord.gg/XF3CXcMzqD) governed by the [Scala Code of Conduct](https://www.scala-lang.org/conduct/). It also takes great effort in supplying a comprehensive and beginner-friendly [documentation](/cats/#documentation).
Based on this core strategy, Cats takes a [modular](motivations.md#modularity) approach and focuses on providing core, [binary compatible](index.md#binary-compatibility-and-versioning), [approachable](motivations.md#approachability) and [efficient](motivations.md#efficiency) abstractions. It provides a welcoming and supportive environment for the [user community](https://discord.gg/XF3CXcMzqD) governed by the [Scala Code of Conduct](https://www.scala-lang.org/conduct/). It also takes great effort in supplying a comprehensive and beginner-friendly [documentation](motivations.md#documentation).

## Where is right-biased Either?
Up through Cats 0.7.x we had `cats.data.Xor`, which was effectively `scala.util.Either`, but right-biased by default and with
Expand Down
2 changes: 1 addition & 1 deletion docs/typeclasses/alternative.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ object Decoder {
Then, we can implement an `Alternative` instance for this type like so:

```scala mdoc:silent
implicit val decoderAlternative = new Alternative[Decoder] {
implicit val decoderAlternative: Alternative[Decoder] = new Alternative[Decoder] {
def pure[A](a: A) = Decoder.from(Function.const(Right(a)))

def empty[A] = Decoder.from(Function.const(Left(new Error("No dice."))))
Expand Down
2 changes: 1 addition & 1 deletion docs/typeclasses/bimonad.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import cats._
import cats.data._
import cats.syntax.all._

implicit val nelBimonad =
implicit val nelBimonad: Bimonad[NonEmptyList] =
new Bimonad[NonEmptyList] {

// in order to have a lawful bimonad `pure` and `extract` need to respect: `nelBimonad.extract(nelBimonad.pure(a)) <-> a`
Expand Down
4 changes: 2 additions & 2 deletions docs/typeclasses/monad.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ the identity function `x => x` (i.e. `flatMap(_)(x => x)`).
```scala mdoc:silent
import cats._

implicit def optionMonad(implicit app: Applicative[Option]) =
implicit def optionMonad(implicit app: Applicative[Option]): Monad[Option] =
new Monad[Option] {
// Define flatMap using Option's flatten method
override def flatMap[A, B](fa: Option[A])(f: A => Option[B]): Option[B] =
Expand Down Expand Up @@ -88,7 +88,7 @@ and therefore stack safe implementation of `tailRecM`.
import cats.Monad
import scala.annotation.tailrec

implicit val optionMonad = new Monad[Option] {
implicit val optionMonad: Monad[Option] = new Monad[Option] {
def flatMap[A, B](fa: Option[A])(f: A => Option[B]): Option[B] = fa.flatMap(f)
def pure[A](a: A): Option[A] = Some(a)

Expand Down
13 changes: 6 additions & 7 deletions mima.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,14 @@ ThisBuild / mimaBinaryIssueFilters ++= {
) ++ // https://github.com/typelevel/cats/pull/4315
Seq(
exclude[MissingClassProblem]("cats.compat.compat$package"),
exclude[MissingClassProblem]("cats.compat.compat$package$")
)
}

ThisBuild / mimaBinaryIssueFilters ++= {
if (tlIsScala3.value)
exclude[MissingClassProblem]("cats.compat.compat$package$"),
ProblemFilters.exclude[MissingClassProblem]("cats.compat.targetName")
) ++ // scala 3 specific filters
Seq(
exclude[DirectMissingMethodProblem]("cats.free.ContravariantCoyoneda.unsafeApply"),
exclude[DirectMissingMethodProblem]("cats.free.Coyoneda.unsafeApply")
) ++ Seq(
ProblemFilters.exclude[MissingClassProblem]("cats.compat.package"),
ProblemFilters.exclude[MissingClassProblem]("cats.compat.package$")
)
else Nil
}
3 changes: 1 addition & 2 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
val sbtTypelevelVersion = "0.4.22"
val sbtTypelevelVersion = "0.5.0-RC7"
addSbtPlugin("org.typelevel" % "sbt-typelevel" % sbtTypelevelVersion)
addSbtPlugin("org.typelevel" % "sbt-typelevel-site" % sbtTypelevelVersion)
addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.5")
addSbtPlugin("com.github.tkawachi" % "sbt-doctest" % "0.10.0")
addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.3.2")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.13.2")
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.14")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0")
19 changes: 7 additions & 12 deletions tests/shared/src/test/scala/cats/tests/CokleisliSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,13 @@ class CokleisliSuite extends SlowCatsSuite {
)
checkAll("Arrow[Cokleisli[NonEmptyList, *, *]]", SerializableTests.serializable(Arrow[Cokleisli[NonEmptyList, *, *]]))

{
implicit def cokleisliIdEq[A, B](implicit evidence: Eq[A => B]): Eq[Cokleisli[Id, A, B]] =
Eq.by[Cokleisli[Id, A, B], A => B](_.run)

checkAll(
"Cokleisli[Id, MiniInt, MiniInt]",
CommutativeArrowTests[Cokleisli[Id, *, *]].commutativeArrow[MiniInt, MiniInt, MiniInt, MiniInt, MiniInt, MiniInt]
)
checkAll("CommutativeArrow[Cokleisli[Id, *, *]]",
SerializableTests.serializable(CommutativeArrow[Cokleisli[Id, *, *]])
)
}
checkAll(
"Cokleisli[Id, MiniInt, MiniInt]",
CommutativeArrowTests[Cokleisli[Id, *, *]].commutativeArrow[MiniInt, MiniInt, MiniInt, MiniInt, MiniInt, MiniInt]
)
checkAll("CommutativeArrow[Cokleisli[Id, *, *]]",
SerializableTests.serializable(CommutativeArrow[Cokleisli[Id, *, *]])
)

test("contramapValue with Id consistent with lmap") {
forAll { (c: Cokleisli[Id, Int, Long], f: MiniInt => Int) =>
Expand Down
4 changes: 2 additions & 2 deletions tests/shared/src/test/scala/cats/tests/EitherSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ class EitherSuite extends CatsSuite {
}

test("leftLiftTo Left") {
forAll { y: String =>
forAll { (y: String) =>
assert(
y.asLeft[Int].leftLiftTo[NonEmptyVector] === Either.left[NonEmptyVector[String], Int](
NonEmptyVector.one(y)
Expand All @@ -384,7 +384,7 @@ class EitherSuite extends CatsSuite {
}

test("leftLiftTo Right") {
forAll { x: Int =>
forAll { (x: Int) =>
assert(x.asRight[String].leftLiftTo[NonEmptyVector] === (Either.right[NonEmptyVector[String], Int](x)))
}
}
Expand Down
3 changes: 0 additions & 3 deletions tests/shared/src/test/scala/cats/tests/KleisliSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ class KleisliSuite extends CatsSuite {
implicit def kleisliEq[F[_], A, B](implicit ev: Eq[A => F[B]]): Eq[Kleisli[F, A, B]] =
Eq.by[Kleisli[F, A, B], A => F[B]](_.run)

implicit def readerEq[A, B](implicit ev: Eq[A => B]): Eq[Reader[A, B]] =
kleisliEq

implicit val eitherTEq: Eq[EitherT[Kleisli[Option, MiniInt, *], Unit, Int]] =
EitherT.catsDataEqForEitherT[Kleisli[Option, MiniInt, *], Unit, Int]
implicit val eitherTEq2: Eq[EitherT[Reader[MiniInt, *], Unit, Int]] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ class RepresentableStoreSuite extends CatsSuite {
{
implicit val pairComonad: Comonad[RepresentableStore[λ[P => (P, P)], Boolean, *]] =
RepresentableStore.catsDataRepresentableStoreComonad[λ[P => (P, P)], Boolean]
implicit val arbStore: Arbitrary[RepresentableStore[λ[P => (P, P)], Boolean, Int]] =
catsLawsArbitraryForRepresentableStore[λ[P => (P, P)], Boolean, Int]
implicit val cogenStore: Cogen[RepresentableStore[λ[P => (P, P)], Boolean, Int]] =
catsLawsCogenForRepresentableStore[λ[P => (P, P)], Boolean, Int]
implicit val eqStore: Eq[RepresentableStore[λ[P => (P, P)], Boolean, Int]] =
cats.laws.discipline.eq.catsLawsEqForRepresentableStore[λ[P => (P, P)], Boolean, Int]
implicit val eqStoreStore
Expand Down

0 comments on commit 512ecc2

Please # to comment.