Skip to content

Commit

Permalink
Merge branch 'main' into add-function-applyn
Browse files Browse the repository at this point in the history
  • Loading branch information
kubukoz committed Feb 27, 2024
2 parents 2010a25 + 84ecd16 commit 04d381d
Show file tree
Hide file tree
Showing 30 changed files with 67 additions and 62 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ jobs:

- name: Upload target directories
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: target-${{ matrix.os }}-${{ matrix.java }}-${{ matrix.scala }}-${{ matrix.project }}
path: targets.tar
Expand Down Expand Up @@ -191,7 +191,7 @@ jobs:
run: sbt +update

- name: Download target directories (2.12, rootJS)
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: target-${{ matrix.os }}-${{ matrix.java }}-2.12-rootJS

Expand All @@ -201,7 +201,7 @@ jobs:
rm targets.tar
- name: Download target directories (2.12, rootJVM)
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: target-${{ matrix.os }}-${{ matrix.java }}-2.12-rootJVM

Expand All @@ -211,7 +211,7 @@ jobs:
rm targets.tar
- name: Download target directories (2.12, rootNative)
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: target-${{ matrix.os }}-${{ matrix.java }}-2.12-rootNative

Expand All @@ -221,7 +221,7 @@ jobs:
rm targets.tar
- name: Download target directories (2.13, rootJS)
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: target-${{ matrix.os }}-${{ matrix.java }}-2.13-rootJS

Expand All @@ -231,7 +231,7 @@ jobs:
rm targets.tar
- name: Download target directories (2.13, rootJVM)
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: target-${{ matrix.os }}-${{ matrix.java }}-2.13-rootJVM

Expand All @@ -241,7 +241,7 @@ jobs:
rm targets.tar
- name: Download target directories (2.13, rootNative)
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: target-${{ matrix.os }}-${{ matrix.java }}-2.13-rootNative

Expand All @@ -251,7 +251,7 @@ jobs:
rm targets.tar
- name: Download target directories (3, rootJS)
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: target-${{ matrix.os }}-${{ matrix.java }}-3-rootJS

Expand All @@ -261,7 +261,7 @@ jobs:
rm targets.tar
- name: Download target directories (3, rootJVM)
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: target-${{ matrix.os }}-${{ matrix.java }}-3-rootJVM

Expand All @@ -271,7 +271,7 @@ jobs:
rm targets.tar
- name: Download target directories (3, rootNative)
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: target-${{ matrix.os }}-${{ matrix.java }}-3-rootNative

Expand Down
7 changes: 6 additions & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version=3.7.17
version=3.8.0
align.openParenCallSite = true
align.openParenDefnSite = true
maxColumn = 120
Expand Down Expand Up @@ -26,3 +26,8 @@ fileOverride {
project.excludeFilters = [
"scalafix/*"
]
rewrite.scala3.convertToNewSyntax = true
runner.dialectOverride.allowSignificantIndentation = false
runner.dialectOverride.allowAsForImportRename = false
runner.dialectOverride.allowStarWildcardImport = false
runner.dialectOverride.allowPostfixStarVarargSplices = false
2 changes: 1 addition & 1 deletion algebra-core/src/main/scala/algebra/ring/Additive.scala
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ trait AdditiveCommutativeGroup[@sp(Int, Long, Float, Double) A]
trait AdditiveSemigroupFunctions[S[T] <: AdditiveSemigroup[T]] {

def isAdditiveCommutative[A](implicit ev: S[A]): Boolean =
ev.isInstanceOf[AdditiveCommutativeSemigroup[_]]
ev.isInstanceOf[AdditiveCommutativeSemigroup[?]]

def plus[@sp(Int, Long, Float, Double) A](x: A, y: A)(implicit ev: S[A]): A =
ev.plus(x, y)
Expand Down
6 changes: 3 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ val disciplineVersion = "1.5.1"

val disciplineMunitVersion = "2.0.0-M3"

val munitVersion = "1.0.0-M10"
val munitVersion = "1.0.0-M11"

val PrimaryJava = JavaSpec.temurin("8")
val LTSJava = JavaSpec.temurin("17")
Expand Down Expand Up @@ -121,12 +121,12 @@ lazy val kernelLaws = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.jvmSettings(commonJvmSettings)
.nativeSettings(commonNativeSettings)

lazy val algebraSettings = Seq[Setting[_]](
lazy val algebraSettings = Seq[Setting[?]](
tlMimaPreviousVersions += "2.2.3",
tlVersionIntroduced := List("2.12", "2.13", "3").map(_ -> "2.7.0").toMap
)

lazy val algebraNativeSettings = Seq[Setting[_]](
lazy val algebraNativeSettings = Seq[Setting[?]](
tlMimaPreviousVersions ~= (_ - "2.2.3"),
tlVersionIntroduced += ("3" -> "2.8.0")
)
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/ApplicativeError.scala
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ object ApplicativeError {
def apply[F[_], E](implicit F: ApplicativeError[F, E]): ApplicativeError[F, E] = F

final private[cats] class LiftFromOptionPartially[F[_]](private val dummy: Boolean = true) extends AnyVal {
def apply[E, A](oa: Option[A], ifEmpty: => E)(implicit F: ApplicativeError[F, _ >: E]): F[A] =
def apply[E, A](oa: Option[A], ifEmpty: => E)(implicit F: ApplicativeError[F, ? >: E]): F[A] =
oa match {
case Some(a) => F.pure(a)
case None => F.raiseError(ifEmpty)
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/Foldable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ trait Foldable[F[_]] extends UnorderedFoldable[F] with FoldableNFunctions[F] { s
* needed.
*/
def traverse_[G[_], A, B](fa: F[A])(f: A => G[B])(implicit G: Applicative[G]): G[Unit] =
foldRight(fa, Always(G.pure(()))) { (a, acc) =>
foldRight(fa, Always(G.unit)) { (a, acc) =>
G.map2Eval(f(a), acc) { (_, _) =>
()
}
Expand Down
6 changes: 3 additions & 3 deletions core/src/main/scala/cats/data/Chain.scala
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ sealed abstract class Chain[+A] extends ChainCompat[A] {
/**
* Returns true if there are no elements in this collection.
*/
def isEmpty: Boolean = !this.isInstanceOf[Chain.NonEmpty[_]]
def isEmpty: Boolean = !this.isInstanceOf[Chain.NonEmpty[?]]

/**
* Returns false if there are no elements in this collection.
Expand All @@ -174,7 +174,7 @@ sealed abstract class Chain[+A] extends ChainCompat[A] {

// Quick check whether the chain is either empty or contains one element only.
@inline private def isEmptyOrSingleton: Boolean =
isEmpty || this.isInstanceOf[Chain.Singleton[_]]
isEmpty || this.isInstanceOf[Chain.Singleton[?]]

/**
* Concatenates this with `c` in O(1) runtime.
Expand Down Expand Up @@ -863,7 +863,7 @@ sealed abstract class Chain[+A] extends ChainCompat[A] {

override def equals(o: Any): Boolean =
o match {
case thatChain: Chain[_] =>
case thatChain: Chain[?] =>
(this: Chain[Any]).===(thatChain: Chain[Any])(Eq.fromUniversalEquals[Any])
case _ => false
}
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/scala/cats/data/EitherT.scala
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ final case class EitherT[F[_], A, B](value: F[Either[A, B]]) {
* res0: Try[Int] = Failure(java.lang.RuntimeException: ERROR!)
* }}}
*/
def getOrRaise[E](e: => E)(implicit F: MonadError[F, _ >: E]): F[B] =
def getOrRaise[E](e: => E)(implicit F: MonadError[F, ? >: E]): F[B] =
getOrElseF(F.raiseError(e))

/**
Expand Down Expand Up @@ -248,7 +248,7 @@ final case class EitherT[F[_], A, B](value: F[Either[A, B]]) {
* res3: util.Try[String] = Failure(java.lang.Exception: sad cats)
* }}}
*/
def rethrowT(implicit F: MonadError[F, _ >: A]): F[B] =
def rethrowT(implicit F: MonadError[F, ? >: A]): F[B] =
F.rethrow(value)

/**
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/data/IorT.scala
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ final case class IorT[F[_], A, B](value: F[Ior[A, B]]) {
* res0: Try[Int] = Failure(java.lang.RuntimeException: ERROR!)
* }}}
*/
def getOrRaise[E](e: => E)(implicit F: MonadError[F, _ >: E]): F[B] =
def getOrRaise[E](e: => E)(implicit F: MonadError[F, ? >: E]): F[B] =
getOrElseF(F.raiseError(e))

def valueOr[BB >: B](f: A => BB)(implicit F: Functor[F], BB: Semigroup[BB]): F[BB] = F.map(value)(_.valueOr(f))
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/data/Kleisli.scala
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ final case class Kleisli[F[_], -A, B](run: A => F[B]) { self =>
}

def flatMapF[C](f: B => F[C])(implicit F: FlatMap[F]): Kleisli[F, A, C] = run match {
case run: StrictConstFunction1[_] => Kleisli(run.andThen(F.flatMap(_: F[B])(f)))
case run: StrictConstFunction1[?] => Kleisli(run.andThen(F.flatMap(_: F[B])(f)))
case _ => Kleisli.shift(a => F.flatMap(run(a))(f))
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/data/OptionT.scala
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ final case class OptionT[F[_], A](value: F[Option[A]]) {
* res0: Try[Int] = Failure(java.lang.RuntimeException: ERROR!)
* }}}
*/
def getOrRaise[E](e: => E)(implicit F: MonadError[F, _ >: E]): F[A] =
def getOrRaise[E](e: => E)(implicit F: MonadError[F, ? >: E]): F[A] =
getOrElseF(F.raiseError(e))

/**
Expand Down
18 changes: 9 additions & 9 deletions core/src/main/scala/cats/instances/try.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,20 @@ trait TryInstances extends TryInstances1 {
override def product[A, B](ta: Try[A], tb: Try[B]): Try[(A, B)] =
(ta, tb) match {
case (Success(a), Success(b)) => Success((a, b))
case (f: Failure[_], _) => castFailure[(A, B)](f)
case (_, f: Failure[_]) => castFailure[(A, B)](f)
case (f: Failure[?], _) => castFailure[(A, B)](f)
case (_, f: Failure[?]) => castFailure[(A, B)](f)
}

override def map2[A, B, Z](ta: Try[A], tb: Try[B])(f: (A, B) => Z): Try[Z] =
(ta, tb) match {
case (Success(a), Success(b)) => Try(f(a, b))
case (f: Failure[_], _) => castFailure[Z](f)
case (_, f: Failure[_]) => castFailure[Z](f)
case (f: Failure[?], _) => castFailure[Z](f)
case (_, f: Failure[?]) => castFailure[Z](f)
}

override def map2Eval[A, B, Z](ta: Try[A], tb: Eval[Try[B]])(f: (A, B) => Z): Eval[Try[Z]] =
ta match {
case f: Failure[_] => Now(castFailure[Z](f))
case f: Failure[?] => Now(castFailure[Z](f))
case Success(a) => tb.map(_.map(f(a, _)))
}

Expand All @@ -71,21 +71,21 @@ trait TryInstances extends TryInstances1 {
def traverse[G[_], A, B](fa: Try[A])(f: A => G[B])(implicit G: Applicative[G]): G[Try[B]] =
fa match {
case Success(a) => G.map(f(a))(Success(_))
case f: Failure[_] => G.pure(castFailure[B](f))
case f: Failure[?] => G.pure(castFailure[B](f))
}

override def mapAccumulate[S, A, B](init: S, fa: Try[A])(f: (S, A) => (S, B)): (S, Try[B]) = {
fa match {
case Success(a) =>
val (snext, b) = f(init, a)
(snext, Success(b))
case f: Failure[_] => (init, castFailure[B](f))
case f: Failure[?] => (init, castFailure[B](f))
}
}

@tailrec final def tailRecM[B, C](b: B)(f: B => Try[Either[B, C]]): Try[C] =
f(b) match {
case f: Failure[_] => castFailure[C](f)
case f: Failure[?] => castFailure[C](f)
case Success(Left(b1)) => tailRecM(b1)(f)
case Success(Right(c)) => Success(c)
}
Expand Down Expand Up @@ -200,7 +200,7 @@ private[instances] object TryInstances {
* A `Failure` can be statically typed as `Try[A]` for all `A`, because it
* does not actually contain an `A` value (as `Success[A]` does).
*/
@inline final def castFailure[A](f: Failure[_]): Try[A] = f.asInstanceOf[Try[A]]
@inline final def castFailure[A](f: Failure[?]): Try[A] = f.asInstanceOf[Try[A]]
}

sealed private[instances] trait TryInstances1 extends TryInstances2 {
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/syntax/applicativeError.scala
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ final private[syntax] class ApplicativeErrorExtensionOps[F[_], E](F: Applicative
}

final class ApplicativeErrorIdOps[E](private val e: E) extends AnyVal {
def raiseError[F[_], A](implicit F: ApplicativeError[F, _ >: E]): F[A] =
def raiseError[F[_], A](implicit F: ApplicativeError[F, ? >: E]): F[A] =
F.raiseError(e)
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/syntax/either.scala
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ final class EitherOps[A, B](private val eab: Either[A, B]) extends AnyVal {
* res0: cats.data.EitherT[Option, CharSequence, Int] = EitherT(Some(Right(3)))
* }}}
*/
def liftTo[F[_]](implicit F: ApplicativeError[F, _ >: A]): F[B] = F.fromEither(eab)
def liftTo[F[_]](implicit F: ApplicativeError[F, ? >: A]): F[B] = F.fromEither(eab)
}

final class EitherObjectOps(private val either: Either.type) extends AnyVal {
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/scala/cats/syntax/monadError.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ trait MonadErrorSyntax {

implicit final def catsSyntaxMonadErrorRethrow[F[_], E, A](
fea: F[Either[E, A]]
)(implicit F: MonadError[F, _ >: E]): MonadErrorRethrowOps[F, E, A] =
)(implicit F: MonadError[F, ? >: E]): MonadErrorRethrowOps[F, E, A] =
new MonadErrorRethrowOps(fea)
}

Expand Down Expand Up @@ -59,7 +59,7 @@ final class MonadErrorOps[F[_], E, A](private val fa: F[A]) extends AnyVal {
}

final class MonadErrorRethrowOps[F[_], E, A](private val fea: F[Either[E, A]]) extends AnyVal {
def rethrow(implicit F: MonadError[F, _ >: E]): F[A] =
def rethrow(implicit F: MonadError[F, ? >: E]): F[A] =
F.flatMap(fea)(
_.fold(F.raiseError, F.pure)
) // dup from the type class impl, due to https://github.com/scala/bug/issues/11562. Once fixed should be able to replace with `F.rethrow(fea)`
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/syntax/option.scala
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ final class OptionOps[A](private val oa: Option[A]) extends AnyVal {

object OptionOps {
final class LiftToPartiallyApplied[F[_], A](oa: Option[A]) {
def apply[E](ifEmpty: => E)(implicit F: ApplicativeError[F, _ >: E]): F[A] =
def apply[E](ifEmpty: => E)(implicit F: ApplicativeError[F, ? >: E]): F[A] =
ApplicativeError.liftFromOption(oa, ifEmpty)
}
}
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/syntax/validated.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ trait ValidatedExtensionSyntax {
}

final class ValidatedExtension[E, A](private val self: Validated[E, A]) extends AnyVal {
def liftTo[F[_]](implicit F: ApplicativeError[F, _ >: E]): F[A] =
def liftTo[F[_]](implicit F: ApplicativeError[F, ? >: E]): F[A] =
F.fromValidated(self)
}

Expand Down
2 changes: 1 addition & 1 deletion docs/typeclasses/semigroup.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def combineAll[A: Semigroup](as: List[A]): A =
```

`Semigroup` isn't powerful enough for us to implement this function - namely, it doesn't give us an identity
or fallback value if the list is empty. We need a power expressive abstraction, which we can find in the
or fallback value if the list is empty. We need a more powerfully expressive abstraction, which we can find in the
`Monoid` type class.

N.B.
Expand Down
4 changes: 2 additions & 2 deletions free/src/main/scala/cats/free/FreeApplicative.scala
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ sealed abstract class FreeApplicative[F[_], A] extends Product with Serializable
argsFLength -= 1

// rip off every `Ap` in `argF` in function position
if (argF.isInstanceOf[Ap[F, _, _]]) {
if (argF.isInstanceOf[Ap[F, ?, ?]]) {
val lengthInitial = argsFLength
// reassociate the functions into a single fn,
// and move the arguments into argsF
Expand All @@ -89,7 +89,7 @@ sealed abstract class FreeApplicative[F[_], A] extends Product with Serializable
argsF ::= ap.fp
argsFLength += 1
argF = ap.fn.asInstanceOf[FA[F, Any]]
argF.isInstanceOf[Ap[F, _, _]]
argF.isInstanceOf[Ap[F, ?, ?]]
}) ()
// consecutive `ap` calls have been queued as operations;
// argF is no longer an `Ap` node, so the entire topmost left-associated
Expand Down
Loading

0 comments on commit 04d381d

Please sign in to comment.