Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
matrix:
os: [ubuntu-22.04]
scala: [2.12, 2.13, 3]
java: [temurin@8]
java: [temurin@17]
project: [rootJS, rootJVM, rootNative]
runs-on: ${{ matrix.os }}
timeout-minutes: 60
Expand All @@ -42,24 +42,24 @@ jobs:
- name: Setup sbt
uses: sbt/setup-sbt@v1

- name: Setup Java (temurin@8)
id: setup-java-temurin-8
if: matrix.java == 'temurin@8'
- name: Setup Java (temurin@17)
id: setup-java-temurin-17
if: matrix.java == 'temurin@17'
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 8
java-version: 17
cache: sbt

- name: sbt update
if: matrix.java == 'temurin@8' && steps.setup-java-temurin-8.outputs.cache-hit == 'false'
if: matrix.java == 'temurin@17' && steps.setup-java-temurin-17.outputs.cache-hit == 'false'
run: sbt +update

- name: Check that workflows are up to date
run: sbt githubWorkflowCheck

- name: Check formatting
if: matrix.java == 'temurin@8' && matrix.os == 'ubuntu-22.04'
if: matrix.java == 'temurin@17' && matrix.os == 'ubuntu-22.04'
run: sbt 'project ${{ matrix.project }}' '++ ${{ matrix.scala }}' scalafmtCheckAll 'project /' scalafmtSbtCheck

- name: scalaJSLink
Expand All @@ -74,11 +74,11 @@ jobs:
run: sbt 'project ${{ matrix.project }}' '++ ${{ matrix.scala }}' test

- name: Check binary compatibility
if: matrix.java == 'temurin@8' && matrix.os == 'ubuntu-22.04'
if: matrix.java == 'temurin@17' && matrix.os == 'ubuntu-22.04'
run: sbt 'project ${{ matrix.project }}' '++ ${{ matrix.scala }}' mimaReportBinaryIssues

- name: Generate API documentation
if: matrix.java == 'temurin@8' && matrix.os == 'ubuntu-22.04'
if: matrix.java == 'temurin@17' && matrix.os == 'ubuntu-22.04'
run: sbt 'project ${{ matrix.project }}' '++ ${{ matrix.scala }}' doc

- name: Make target directories
Expand All @@ -103,7 +103,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-22.04]
java: [temurin@8]
java: [temurin@17]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout current branch (full)
Expand All @@ -114,17 +114,17 @@ jobs:
- name: Setup sbt
uses: sbt/setup-sbt@v1

- name: Setup Java (temurin@8)
id: setup-java-temurin-8
if: matrix.java == 'temurin@8'
- name: Setup Java (temurin@17)
id: setup-java-temurin-17
if: matrix.java == 'temurin@17'
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 8
java-version: 17
cache: sbt

- name: sbt update
if: matrix.java == 'temurin@8' && steps.setup-java-temurin-8.outputs.cache-hit == 'false'
if: matrix.java == 'temurin@17' && steps.setup-java-temurin-17.outputs.cache-hit == 'false'
run: sbt +update

- name: Download target directories (2.12, rootJS)
Expand Down Expand Up @@ -247,7 +247,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-22.04]
java: [temurin@8]
java: [temurin@17]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout current branch (full)
Expand All @@ -258,17 +258,17 @@ jobs:
- name: Setup sbt
uses: sbt/setup-sbt@v1

- name: Setup Java (temurin@8)
id: setup-java-temurin-8
if: matrix.java == 'temurin@8'
- name: Setup Java (temurin@17)
id: setup-java-temurin-17
if: matrix.java == 'temurin@17'
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 8
java-version: 17
cache: sbt

- name: sbt update
if: matrix.java == 'temurin@8' && steps.setup-java-temurin-8.outputs.cache-hit == 'false'
if: matrix.java == 'temurin@17' && steps.setup-java-temurin-17.outputs.cache-hit == 'false'
run: sbt +update

- name: Submit Dependencies
Expand Down
18 changes: 9 additions & 9 deletions .mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ pull_request_rules:
- or:
- body~=labels:.*early-semver-patch
- body~=labels:.*early-semver-minor
- status-success=Test (ubuntu-22.04, 2.12, temurin@8, rootJS)
- status-success=Test (ubuntu-22.04, 2.12, temurin@8, rootJVM)
- status-success=Test (ubuntu-22.04, 2.12, temurin@8, rootNative)
- status-success=Test (ubuntu-22.04, 2.13, temurin@8, rootJS)
- status-success=Test (ubuntu-22.04, 2.13, temurin@8, rootJVM)
- status-success=Test (ubuntu-22.04, 2.13, temurin@8, rootNative)
- status-success=Test (ubuntu-22.04, 3, temurin@8, rootJS)
- status-success=Test (ubuntu-22.04, 3, temurin@8, rootJVM)
- status-success=Test (ubuntu-22.04, 3, temurin@8, rootNative)
- status-success=Test (ubuntu-22.04, 2.12, temurin@17, rootJS)
- status-success=Test (ubuntu-22.04, 2.12, temurin@17, rootJVM)
- status-success=Test (ubuntu-22.04, 2.12, temurin@17, rootNative)
- status-success=Test (ubuntu-22.04, 2.13, temurin@17, rootJS)
- status-success=Test (ubuntu-22.04, 2.13, temurin@17, rootJVM)
- status-success=Test (ubuntu-22.04, 2.13, temurin@17, rootNative)
- status-success=Test (ubuntu-22.04, 3, temurin@17, rootJS)
- status-success=Test (ubuntu-22.04, 3, temurin@17, rootJVM)
- status-success=Test (ubuntu-22.04, 3, temurin@17, rootNative)
actions:
merge: {}
- name: Label core PRs
Expand Down
6 changes: 3 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import com.typesafe.tools.mima.core.{MissingClassProblem, ProblemFilters}

val scala212 = "2.12.21"
val scala213 = "2.13.18"
val scala3 = "3.3.8"
val scala3 = "3.9.0"

ThisBuild / crossScalaVersions := Seq(scala212, scala213, scala3)
ThisBuild / scalaVersion := scala3
ThisBuild / tlBaseVersion := "3.5"
ThisBuild / tlBaseVersion := "3.6"
ThisBuild / organization := "org.typelevel"
ThisBuild / githubWorkflowJavaVersions := Seq(JavaSpec.temurin("17"))

val catsVersion = "2.13.0"
val munitVersion = "1.3.6"
Expand All @@ -26,7 +27,6 @@ val commonOptions = List(
)

val scala3Options = List(
"-source:future",
"-Xmax-inlines",
"64",
"-Wvalue-discard",
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/scala-3/cats/derived/DerivedApplicative.scala
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ object DerivedApplicative:
DerivedApply.Product[T, F]:

final override def pure[A](x: A): F[A] =
inst.construct([f[_]] => (F: T[f]) => F.pure[A](x))
inst.construct: [f[_]] =>
F => F.pure[A](x)

object Strict:
given product[F[_]: ProductInstancesOf[Applicative]]: DerivedApplicative[F] =
Expand Down
8 changes: 6 additions & 2 deletions core/src/main/scala-3/cats/derived/DerivedApply.scala
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,13 @@ object DerivedApply:

trait Product[T[f[_]] <: Apply[f], F[_]](using inst: ProductInstances[T, F]) extends Apply[F]:
private lazy val F = DerivedFunctor.Strict.product(using inst.widen).instance
final override def map[A, B](fa: F[A])(f: A => B): F[B] = F.map(fa)(f)

final override def map[A, B](fa: F[A])(f: A => B): F[B] =
F.map(fa)(f)

final override def ap[A, B](ff: F[A => B])(fa: F[A]): F[B] =
inst.map2(ff, fa)([f[_]] => (F: T[f], ff: f[A => B], fa: f[A]) => F.ap(ff)(fa))
inst.map2(ff, fa): [f[_]] =>
(F, ff, fa) => F.ap(ff)(fa)

object Strict:
given product[F[_]: ProductInstancesOf[Apply]]: DerivedApply[F] =
Expand Down
10 changes: 6 additions & 4 deletions core/src/main/scala-3/cats/derived/DerivedBifoldable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -76,23 +76,25 @@ object DerivedBifoldable:

trait Product[T[f[_, _]] <: Bifoldable[f], F[_, _]](using inst: ProductInstances[T, F]) extends Bifoldable[F]:
final override def bifoldLeft[A, B, C](fab: F[A, B], c: C)(f: (C, A) => C, g: (C, B) => C): C =
inst.foldLeft(fab)(c)([f[_, _]] => (c: C, F: T[f], fab: f[A, B]) => F.bifoldLeft(fab, c)(f, g))
inst.foldLeft(fab)(c): [f[_, _]] =>
(c, F, fab) => F.bifoldLeft(fab, c)(f, g)

final override def bifoldRight[A, B, C](fab: F[A, B], c: Eval[C])(
f: (A, Eval[C]) => Eval[C],
g: (B, Eval[C]) => Eval[C]
): Eval[C] = inst.foldRight(fab)(c): [f[_, _]] =>
(F: T[f], fab: f[A, B], c: Eval[C]) => Eval.defer(F.bifoldRight(fab, c)(f, g))
(F, fab, c) => Eval.defer(F.bifoldRight(fab, c)(f, g))

trait Coproduct[T[f[_, _]] <: Bifoldable[f], F[_, _]](using inst: CoproductInstances[T, F]) extends Bifoldable[F]:
final override def bifoldLeft[A, B, C](fab: F[A, B], c: C)(f: (C, A) => C, g: (C, B) => C): C =
inst.fold(fab)([f[_, _]] => (F: T[f], fab: f[A, B]) => F.bifoldLeft(fab, c)(f, g))
inst.fold(fab): [f[_, _]] =>
(F, fab) => F.bifoldLeft(fab, c)(f, g)

final override def bifoldRight[A, B, C](fab: F[A, B], c: Eval[C])(
f: (A, Eval[C]) => Eval[C],
g: (B, Eval[C]) => Eval[C]
): Eval[C] = inst.fold(fab): [f[_, _]] =>
(F: T[f], fab: f[A, B]) => Eval.defer(F.bifoldRight(fab, c)(f, g))
(F, fab) => Eval.defer(F.bifoldRight(fab, c)(f, g))

object Strict:
given product[F[_, _]: ProductInstancesOf[Bifoldable]]: DerivedBifoldable[F] =
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/scala-3/cats/derived/DerivedBifunctor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ object DerivedBifunctor:

trait Generic[T[f[_, _]] <: Bifunctor[f], F[_, _]](using inst: Instances[T, F]) extends Bifunctor[F]:
final override def bimap[A, B, C, D](fab: F[A, B])(f: A => C, g: B => D): F[C, D] =
inst.map(fab)([f[_, _]] => (F: T[f], fa: f[A, B]) => F.bimap(fa)(f, g))
inst.map(fab): [f[_, _]] =>
(F, fa) => F.bimap(fa)(f, g)

object Strict:
given product[F[_, _]: ProductInstancesOf[Bifunctor]]: DerivedBifunctor[F] = gen
Expand Down
10 changes: 5 additions & 5 deletions core/src/main/scala-3/cats/derived/DerivedBitraverse.scala
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ object DerivedBitraverse:
final override def bitraverse[G[_], A, B, C, D](fab: F[A, B])(f: A => G[C], g: B => G[D])(using
G: Applicative[G]
): G[F[C, D]] =
val pure = [a] => (x: a) => G.pure(x)
val map = [a, b] => (ga: G[a], f: a => b) => G.map(ga)(f)
val ap = [a, b] => (gf: G[a => b], ga: G[a]) => G.ap(gf)(ga)
inst.traverse[A, B, G, C, D](fab)(map)(pure)(ap)([f[_, _]] => (F: T[f], fab: f[A, B]) => F.bitraverse(fab)(f, g))
inst.traverse[A, B, G, C, D](fab)([a, b] => (ga, f) => G.map(ga)(f))([a] => x => G.pure(x))([a, b] =>
(gf, ga) => G.ap(gf)(ga)
): [f[_, _]] =>
(F, fab) => F.bitraverse(fab)(f, g)

trait Coproduct[T[f[_, _]] <: Bitraverse[f], F[_, _]](using inst: CoproductInstances[T, F])
extends Bitraverse[F]
Expand All @@ -109,7 +109,7 @@ object DerivedBitraverse:
final override def bitraverse[G[_], A, B, C, D](fab: F[A, B])(f: A => G[C], g: B => G[D])(using
G: Applicative[G]
): G[F[C, D]] = inst.fold(fab): [f[a, b] <: F[a, b]] =>
(F: T[f], fa: f[A, B]) => G.widen[f[C, D], F[C, D]](F.bitraverse(fa)(f, g))
(F, fa) => G.widen[f[C, D], F[C, D]](F.bitraverse(fa)(f, g))

object Strict:
given product[F[_, _]: ProductInstancesOf[Bitraverse]]: DerivedBitraverse[F] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ object DerivedContravariant:

trait Generic[T[f[_]] <: Contravariant[f], F[_]](using inst: Instances[T, F]) extends Contravariant[F]:
final override def contramap[A, B](fa: F[A])(f: B => A): F[B] =
inst.map(fa)([f[_]] => (T: T[f], fa: f[A]) => T.contramap(fa)(f))
inst.map(fa): [f[_]] =>
(T, fa) => T.contramap(fa)(f)

object Strict:
given product[F[_]: ProductInstancesOf[Contravariant]]: DerivedContravariant[F] = generic
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/scala-3/cats/derived/DerivedEmpty.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ object DerivedEmpty:

object Strict:
given product[A: ProductInstancesOf[Empty]]: DerivedEmpty[A] =
Empty(ProductInstances.construct([a] => (A: Empty[a]) => A.empty))
Empty(ProductInstances.construct([a] => A => A.empty))

@nowarn("id=E197")
inline given coproduct[A: CoproductGeneric]: DerivedEmpty[A] =
Empty(CoproductGeneric.withOnly[Empty |: Derived, A]([a <: A] => (A: (Empty |: Derived)[a]) => A.unify.empty))
Empty(CoproductGeneric.withOnly[Empty |: Derived, A]([a <: A] => A => A.unify.empty))
5 changes: 3 additions & 2 deletions core/src/main/scala-3/cats/derived/DerivedEmptyK.scala
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,10 @@ object DerivedEmptyK:

object Strict:
given product[F[_]: ProductInstancesOf[EmptyK]]: DerivedEmptyK[F] = new EmptyK[F]:
def empty[A]: F[A] = ProductInstances.construct([f[_]] => (F: EmptyK[f]) => F.empty[A])
def empty[A]: F[A] = ProductInstances.construct: [f[_]] =>
F => F.empty[A]

@nowarn("id=E197")
inline given coproduct[F[_]: CoproductGeneric]: DerivedEmptyK[F] =
CoproductGeneric.withOnly[EmptyK |: Derived, EmptyK[F]]: [f[x] <: F[x]] =>
(F: (EmptyK |: Derived)[f]) => F.asInstanceOf[EmptyK[F]]
F => F.asInstanceOf[EmptyK[F]]
6 changes: 3 additions & 3 deletions core/src/main/scala-3/cats/derived/DerivedEq.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ object DerivedEq:
new Coproduct[Eq, A] {}

trait Product[F[x] <: Eq[x], A](using inst: ProductInstances[F, A]) extends Eq[A]:
final override def eqv(x: A, y: A): Boolean = inst.foldLeft2(x, y)(true: Boolean): [t] =>
(acc: Boolean, eqt: F[t], x: t, y: t) => Complete(!eqt.eqv(x, y))(false)(acc)
final override def eqv(x: A, y: A): Boolean = inst.foldLeft2(x, y)(true): [t] =>
(acc, eqt, x, y) => Complete(!eqt.eqv(x, y))(false)(acc)

trait Coproduct[F[x] <: Eq[x], A](using inst: CoproductInstances[F, A]) extends Eq[A]:
final override def eqv(x: A, y: A): Boolean = inst.fold2(x, y)(false): [t] =>
(eqt: F[t], x: t, y: t) => eqt.eqv(x, y)
(eqt, x, y) => eqt.eqv(x, y)

object Strict:
export DerivedEq.coproduct
Expand Down
12 changes: 8 additions & 4 deletions core/src/main/scala-3/cats/derived/DerivedFoldable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,21 @@ object DerivedFoldable:

trait Product[T[f[_]] <: Foldable[f], F[_]](using inst: ProductInstances[T, F]) extends Foldable[F]:
final override def foldLeft[A, B](fa: F[A], b: B)(f: (B, A) => B): B =
inst.foldLeft(fa)(b)([f[_]] => (b: B, F: T[f], fa: f[A]) => F.foldLeft(fa, b)(f))
inst.foldLeft(fa)(b): [f[_]] =>
(b, F, fa) => F.foldLeft(fa, b)(f)

final override def foldRight[A, B](fa: F[A], lb: Eval[B])(f: (A, Eval[B]) => Eval[B]): Eval[B] =
inst.foldRight(fa)(lb)([f[_]] => (F: T[f], fa: f[A], lb: Eval[B]) => Eval.defer(F.foldRight(fa, lb)(f)))
inst.foldRight(fa)(lb): [f[_]] =>
(F, fa, lb) => Eval.defer(F.foldRight(fa, lb)(f))

trait Coproduct[T[f[_]] <: Foldable[f], F[_]](using inst: CoproductInstances[T, F]) extends Foldable[F]:
final override def foldLeft[A, B](fa: F[A], b: B)(f: (B, A) => B): B =
inst.fold(fa)([f[_]] => (F: T[f], fa: f[A]) => F.foldLeft(fa, b)(f))
inst.fold(fa): [f[_]] =>
(F, fa) => F.foldLeft(fa, b)(f)

final override def foldRight[A, B](fa: F[A], lb: Eval[B])(f: (A, Eval[B]) => Eval[B]): Eval[B] =
inst.fold(fa)([f[_]] => (F: T[f], fa: f[A]) => Eval.defer(F.foldRight(fa, lb)(f)))
inst.fold(fa): [f[_]] =>
(F, fa) => Eval.defer(F.foldRight(fa, lb)(f))

object Strict:
given product[F[_]: ProductInstancesOf[Foldable]]: DerivedFoldable[F] =
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/scala-3/cats/derived/DerivedFunctor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ object DerivedFunctor:

trait Generic[T[f[_]] <: Functor[f], F[_]](using inst: Instances[T, F]) extends Functor[F]:
final override def map[A, B](fa: F[A])(f: A => B): F[B] =
inst.map(fa)([f[_]] => (F: T[f], fa: f[A]) => F.map(fa)(f))
inst.map(fa): [f[_]] =>
(F, fa) => F.map(fa)(f)

object Strict:
given product[F[_]: ProductInstancesOf[Functor]]: DerivedFunctor[F] = generic
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/scala-3/cats/derived/DerivedGroup.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ object DerivedGroup:
Strict.product(using inst.unify)

trait Product[F[x] <: Group[x], A: ProductInstancesOf[F]] extends DerivedMonoid.Product[F, A], Group[A]:
final override def inverse(a: A): A = ProductInstances.map(a)([a] => (F: F[a], x: a) => F.inverse(x))
final override def inverse(a: A): A = ProductInstances.map(a): [a] =>
(F, x) => F.inverse(x)

object Strict:
given product[A: ProductInstancesOf[Group]]: DerivedGroup[A] =
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/scala-3/cats/derived/DerivedHash.scala
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ object DerivedHash:
MurmurHash3.finalizeHash(hash, arity)

trait Coproduct[F[x] <: Hash[x], A](using inst: CoproductInstances[F, A]) extends DerivedEq.Coproduct[F, A], Hash[A]:
final override def hash(x: A): Int = inst.fold[Int](x)([t] => (h: F[t], x: t) => h.hash(x))
final override def hash(x: A): Int = inst.fold[Int](x): [t] =>
(h, x) => h.hash(x)

object Strict:
export DerivedHash.coproduct
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/scala-3/cats/derived/DerivedInvariant.scala
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ object DerivedInvariant:

trait Generic[T[f[_]] <: Invariant[f], F[_]](using inst: Instances[T, F]) extends Invariant[F]:
final override def imap[A, B](fa: F[A])(f: A => B)(g: B => A): F[B] =
inst.map(fa)([f[_]] => (F: T[f], fa: f[A]) => F.imap(fa)(f)(g))
inst.map(fa): [f[_]] =>
(F, fa) => F.imap(fa)(f)(g)

object Strict:
given product[F[_]: ProductInstancesOf[Invariant]]: DerivedInvariant[F] = generic
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/scala-3/cats/derived/DerivedMonoid.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ object DerivedMonoid:
extends DerivedSemigroup.Product[F, A],
Monoid[A]:
final override lazy val empty: A =
inst.construct([a] => (F: F[a]) => F.empty)
inst.construct: [a] =>
F => F.empty

object Strict:
given product[A: ProductInstancesOf[Monoid]]: DerivedMonoid[A] =
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/scala-3/cats/derived/DerivedMonoidK.scala
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ object DerivedMonoidK:
DerivedSemigroupK.Product[T, F]:

final override def empty[A]: F[A] =
inst.construct([f[_]] => (F: T[f]) => F.empty[A])
inst.construct: [f[_]] =>
F => F.empty[A]

object Strict:
given product[F[_]: ProductInstancesOf[MonoidK]]: DerivedMonoidK[F] =
Expand Down
Loading
Loading