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
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Scala Steward: Reformat with scalafmt 3.9.10
a360fb2dafdd84e58a2244d07b182003100e5b69
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "3.9.4"
version = "3.9.10"
runner.dialect = scala213
align.preset = none
maxColumn = 120
Expand Down
8 changes: 4 additions & 4 deletions core/src/main/scala-3/cats/derived/DerivedBifoldable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ object DerivedBifoldable:
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))
): 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))

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 =
Expand All @@ -91,8 +91,8 @@ object DerivedBifoldable:
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))
): Eval[C] = inst.fold(fab): [f[_, _]] =>
(F: T[f], fab: f[A, B]) => Eval.defer(F.bifoldRight(fab, c)(f, g))

object Strict:
given product[F[_, _]: ProductInstancesOf[Bifoldable]]: DerivedBifoldable[F] =
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/scala-3/cats/derived/DerivedBitraverse.scala
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ 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))
): 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))

object Strict:
given product[F[_, _]: ProductInstancesOf[Bitraverse]]: DerivedBitraverse[F] =
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/scala-3/cats/derived/DerivedEmptyK.scala
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,5 @@ object DerivedEmptyK:

@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]]
CoproductGeneric.withOnly[EmptyK |: Derived, EmptyK[F]]: [f[x] <: F[x]] =>
(F: (EmptyK |: Derived)[f]) => F.asInstanceOf[EmptyK[F]]
8 changes: 4 additions & 4 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: Boolean): [t] =>
(acc: Boolean, eqt: F[t], x: t, y: t) => 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)
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)

object Strict:
export DerivedEq.coproduct
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/scala-3/cats/derived/DerivedHash.scala
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ object DerivedHash:
val prefix = x.productPrefix.hashCode
if arity <= 0 then prefix
else
val hash = inst.foldLeft[Int](x)(MurmurHash3.mix(MurmurHash3.productSeed, prefix)):
[t] => (acc: Int, h: F[t], x: t) => MurmurHash3.mix(acc, h.hash(x))
val hash = inst.foldLeft[Int](x)(MurmurHash3.mix(MurmurHash3.productSeed, prefix)): [t] =>
(acc: Int, h: F[t], x: t) => MurmurHash3.mix(acc, h.hash(x))
MurmurHash3.finalizeHash(hash, arity)

trait Coproduct[F[x] <: Hash[x], A](using inst: CoproductInstances[F, A]) extends DerivedEq.Coproduct[F, A], Hash[A]:
Expand Down
13 changes: 6 additions & 7 deletions core/src/main/scala-3/cats/derived/DerivedOrder.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,15 @@ object DerivedOrder:

trait Product[T[x] <: Order[x], A](using inst: ProductInstances[T, A]) extends Order[A]:
def compare(x: A, y: A): Int =
inst.foldLeft2(x, y)(0: Int):
[t] =>
(acc: Int, ord: T[t], t0: t, t1: t) =>
val cmp = ord.compare(t0, t1)
Complete(cmp != 0)(cmp)(acc)
inst.foldLeft2(x, y)(0: Int): [t] =>
(acc: Int, ord: T[t], t0: t, t1: t) =>
val cmp = ord.compare(t0, t1)
Complete(cmp != 0)(cmp)(acc)

trait Coproduct[T[x] <: Order[x], A](using inst: CoproductInstances[T, A]) extends Order[A]:
def compare(x: A, y: A): Int =
inst.fold2(x, y)((x: Int, y: Int) => x - y):
[t] => (ord: T[t], t0: t, t1: t) => ord.compare(t0, t1)
inst.fold2(x, y)((x: Int, y: Int) => x - y): [t] =>
(ord: T[t], t0: t, t1: t) => ord.compare(t0, t1)

object Strict:
export DerivedOrder.coproduct
Expand Down
13 changes: 6 additions & 7 deletions core/src/main/scala-3/cats/derived/DerivedPartialOrder.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,15 @@ object DerivedPartialOrder:

trait Product[T[x] <: PartialOrder[x], A](using inst: ProductInstances[T, A]) extends PartialOrder[A]:
def partialCompare(x: A, y: A): Double =
inst.foldLeft2(x, y)(0: Double):
[t] =>
(acc: Double, ord: T[t], t0: t, t1: t) =>
val cmp = ord.partialCompare(t0, t1)
Complete(cmp != 0)(cmp)(acc)
inst.foldLeft2(x, y)(0: Double): [t] =>
(acc: Double, ord: T[t], t0: t, t1: t) =>
val cmp = ord.partialCompare(t0, t1)
Complete(cmp != 0)(cmp)(acc)

trait Coproduct[T[x] <: PartialOrder[x], A](using inst: CoproductInstances[T, A]) extends PartialOrder[A]:
def partialCompare(x: A, y: A): Double =
inst.fold2(x, y)(Double.NaN: Double):
[t] => (ord: T[t], t0: t, t1: t) => ord.partialCompare(t0, t1)
inst.fold2(x, y)(Double.NaN: Double): [t] =>
(ord: T[t], t0: t, t1: t) => ord.partialCompare(t0, t1)

object Strict:
export DerivedPartialOrder.coproduct
Expand Down
22 changes: 10 additions & 12 deletions core/src/main/scala-3/cats/derived/DerivedReducible.scala
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,20 @@ object DerivedReducible:

final override def reduceLeftTo[A, B](fa: F[A])(f: A => B)(g: (B, A) => B): B =
inst
.foldLeft[A, Option[B]](fa)(None):
[f[_]] =>
(acc: Option[B], F: T[f], fa: f[A]) =>
acc match
case Some(b) => Some(F.foldLeft(fa, b)(g))
case None => F.reduceLeftToOption(fa)(f)(g)
.foldLeft[A, Option[B]](fa)(None): [f[_]] =>
(acc: Option[B], F: T[f], fa: f[A]) =>
acc match
case Some(b) => Some(F.foldLeft(fa, b)(g))
case None => F.reduceLeftToOption(fa)(f)(g)
.get

final override def reduceRightTo[A, B](fa: F[A])(f: A => B)(g: (A, Eval[B]) => Eval[B]): Eval[B] =
inst
.foldRight[A, Eval[Option[B]]](fa)(evalNone):
[f[_]] =>
(F: T[f], fa: f[A], acc: Eval[Option[B]]) =>
acc.flatMap:
case Some(b) => F.foldRight(fa, Eval.now(b))(g).map(Some.apply)
case None => F.reduceRightToOption(fa)(f)(g)
.foldRight[A, Eval[Option[B]]](fa)(evalNone): [f[_]] =>
(F: T[f], fa: f[A], acc: Eval[Option[B]]) =>
acc.flatMap:
case Some(b) => F.foldRight(fa, Eval.now(b))(g).map(Some.apply)
case None => F.reduceRightToOption(fa)(f)(g)
.map(_.get)

trait Coproduct[T[f[_]] <: Reducible[f], F[_]](using inst: CoproductInstances[T, F])
Expand Down
Loading