Skip to content

Commit

Permalink
Move Id instances into implicit scope for Scala 3
Browse files Browse the repository at this point in the history
  • Loading branch information
joroKr21 committed May 26, 2021
1 parent dd4dc93 commit 1cbbbbc
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 11 deletions.
4 changes: 3 additions & 1 deletion core/src/main/scala/cats/Invariant.scala
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ import scala.util.control.TailCalls.TailRec

@suppressUnusedImportWarningForScalaVersionSpecific
object Invariant extends ScalaVersionSpecificInvariantInstances with InvariantInstances0 {
implicit def catsInstancesForId: Distributive[Id] with Comonad[Id] = cats.catsInstancesForId
implicit def catsInstancesForId
: Distributive[Id] with Bimonad[Id] with CommutativeMonad[Id] with NonEmptyTraverse[Id] =
cats.catsInstancesForId
implicit def catsMonadErrorForEither[A]: MonadError[Either[A, *], A] =
cats.instances.either.catsStdInstancesForEither[A]
implicit def catsInstancesForOption
Expand Down
6 changes: 3 additions & 3 deletions core/src/main/scala/cats/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ package object cats {
*/
type Id[A] = A
type Endo[A] = A => A
implicit val catsInstancesForId
: Bimonad[Id] with CommutativeMonad[Id] with Comonad[Id] with NonEmptyTraverse[Id] with Distributive[Id] =
new Bimonad[Id] with CommutativeMonad[Id] with Comonad[Id] with NonEmptyTraverse[Id] with Distributive[Id] {

val catsInstancesForId: Bimonad[Id] with CommutativeMonad[Id] with NonEmptyTraverse[Id] with Distributive[Id] =
new Bimonad[Id] with CommutativeMonad[Id] with NonEmptyTraverse[Id] with Distributive[Id] {
def pure[A](a: A): A = a
def extract[A](a: A): A = a
def flatMap[A, B](a: A)(f: A => B): B = f(a)
Expand Down
4 changes: 1 addition & 3 deletions laws/src/main/scala/cats/laws/NonEmptyTraverseLaws.scala
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package cats.laws

// The `catsInstancesForId` import is necessary to work around a Dotty
// issue related to https://github.com/lampepfl/dotty/issues/9067.
import cats.{catsInstancesForId, Apply, Id, NonEmptyTraverse, Semigroup}
import cats.{Apply, Id, NonEmptyTraverse, Semigroup}
import cats.data.{Const, Nested}
import cats.syntax.nonEmptyTraverse._
import cats.syntax.reducible._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import cats.syntax.parallel._
import cats.syntax.traverse._
import cats.syntax.eq._
import org.scalacheck.Prop._
import cats.catsInstancesForId
import cats.kernel.{Eq, Order}
import cats.laws.discipline.eq._

Expand Down
1 change: 0 additions & 1 deletion tests/src/test/scala/cats/tests/IdSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package cats.tests

import cats.{Bimonad, CommutativeMonad, Id, Reducible, Traverse}
import cats.laws.discipline._
import cats.catsInstancesForId

class IdSuite extends CatsSuite {
implicit val iso: SemigroupalTests.Isomorphisms[Id] =
Expand Down
1 change: 0 additions & 1 deletion tests/src/test/scala/cats/tests/MonadSuite.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package cats.tests

import cats.{Eval, Id, Monad}
import cats.catsInstancesForId
import cats.data.{IndexedStateT, StateT}
import cats.syntax.apply._
import cats.syntax.monad._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import cats.Id
import cats.syntax.unorderedTraverse._
import cats.syntax.eq._
import org.scalacheck.Prop._
import cats.catsInstancesForId

class UnorderedTraverseSuite extends CatsSuite {
test("UnorderedTraverse[Set[Int]].unorderedTraverse via syntax") {
Expand Down

0 comments on commit 1cbbbbc

Please sign in to comment.