From 75451cc5456a4b51da14f981a67ae445f5096696 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Miguel=20Mej=C3=ADa=20Su=C3=A1rez?= Date: Fri, 20 May 2022 23:47:19 -0500 Subject: [PATCH] Remove simulacrum --- .scalafix.conf | 10 ------- DESIGN.md | 5 ++-- .../src/main/scala/alleycats/ConsK.scala | 11 +------ .../src/main/scala/alleycats/Empty.scala | 12 +------- .../src/main/scala/alleycats/EmptyK.scala | 12 +------- .../src/main/scala/alleycats/Extract.scala | 12 +------- .../src/main/scala/alleycats/One.scala | 11 +------ .../src/main/scala/alleycats/Pure.scala | 11 +------ .../src/main/scala/alleycats/Zero.scala | 12 +------- build.sbt | 13 +-------- core/src/main/scala/cats/Align.scala | 12 +------- core/src/main/scala/cats/Alternative.scala | 12 ++------ core/src/main/scala/cats/Applicative.scala | 12 ++------ core/src/main/scala/cats/Apply.scala | 15 ++-------- core/src/main/scala/cats/Bifoldable.scala | 12 +------- core/src/main/scala/cats/Bifunctor.scala | 10 +------ core/src/main/scala/cats/Bimonad.scala | 12 +------- core/src/main/scala/cats/Bitraverse.scala | 16 ++-------- core/src/main/scala/cats/CoflatMap.scala | 12 +------- .../scala/cats/CommutativeApplicative.scala | 11 +------ .../main/scala/cats/CommutativeApply.scala | 11 +------ .../main/scala/cats/CommutativeFlatMap.scala | 12 +------- .../main/scala/cats/CommutativeMonad.scala | 12 +------- core/src/main/scala/cats/Comonad.scala | 12 +------- core/src/main/scala/cats/Contravariant.scala | 11 +------ .../scala/cats/ContravariantMonoidal.scala | 12 +------- .../scala/cats/ContravariantSemigroupal.scala | 12 +------- core/src/main/scala/cats/Distributive.scala | 11 +------ core/src/main/scala/cats/FlatMap.scala | 25 +++++----------- core/src/main/scala/cats/Foldable.scala | 29 ++++++------------- core/src/main/scala/cats/Functor.scala | 16 ++-------- core/src/main/scala/cats/FunctorFilter.scala | 11 +------ core/src/main/scala/cats/Invariant.scala | 12 ++------ .../main/scala/cats/InvariantMonoidal.scala | 12 +------- .../scala/cats/InvariantSemigroupal.scala | 12 +------- core/src/main/scala/cats/Monad.scala | 18 +++--------- core/src/main/scala/cats/MonoidK.scala | 12 +------- .../main/scala/cats/NonEmptyAlternative.scala | 13 ++------- .../main/scala/cats/NonEmptyTraverse.scala | 12 +------- core/src/main/scala/cats/Reducible.scala | 17 ++--------- core/src/main/scala/cats/SemigroupK.scala | 14 ++------- core/src/main/scala/cats/Semigroupal.scala | 11 +------ core/src/main/scala/cats/Traverse.scala | 12 +------- core/src/main/scala/cats/TraverseFilter.scala | 12 +------- .../main/scala/cats/UnorderedFoldable.scala | 13 ++------- .../main/scala/cats/UnorderedTraverse.scala | 12 +------- core/src/main/scala/cats/arrow/Arrow.scala | 16 ++-------- .../main/scala/cats/arrow/ArrowChoice.scala | 14 ++------- core/src/main/scala/cats/arrow/Category.scala | 12 +------- core/src/main/scala/cats/arrow/Choice.scala | 14 ++------- .../scala/cats/arrow/CommutativeArrow.scala | 12 +------- core/src/main/scala/cats/arrow/Compose.scala | 14 +-------- .../main/scala/cats/arrow/Profunctor.scala | 12 +------- core/src/main/scala/cats/arrow/Strong.scala | 12 +------- .../main/scala/cats/syntax/alternative.scala | 10 +++---- core/src/main/scala/cats/syntax/group.scala | 1 - core/src/main/scala/cats/syntax/monoid.scala | 2 +- .../main/scala/cats/syntax/semigroup.scala | 2 +- docs/colophon.md | 1 - docs/faq.md | 6 ---- docs/guidelines.md | 4 +-- docs/typeclasses.md | 5 +--- project/plugins.sbt | 1 - 63 files changed, 99 insertions(+), 628 deletions(-) delete mode 100644 .scalafix.conf diff --git a/.scalafix.conf b/.scalafix.conf deleted file mode 100644 index d26fd2b0a5..0000000000 --- a/.scalafix.conf +++ /dev/null @@ -1,10 +0,0 @@ -rules = [ - AddSerializable - AddImplicitNotFound - TypeClassSupport -] - -TypeClassSupport.opsObjectDeprecation = { - message = "Use cats.syntax object imports" - since = "2.2.0" -} diff --git a/DESIGN.md b/DESIGN.md index 05e27ddcb4..d023c8696f 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -7,7 +7,6 @@ ensure correctness. Cats will be designed to use modern *best practices*: - * [simulacrum](https://github.com/typelevel/simulacrum) for minimizing type class boilerplate * [machinist](https://github.com/typelevel/machinist) for optimizing implicit operators * [scalacheck](http://scalacheck.org) for property-based testing * [discipline](https://github.com/typelevel/discipline) for encoding and testing laws @@ -36,11 +35,11 @@ Cats provides the following modules: * `core`: Definitions for widely-used type classes and data types. * `laws`: The encoded laws for type classes defined in `core`, exported to assist third-party testing. - * `kernel`: Definitions for the basic algebraic type classes + * `kernel`: Definitions for the basic algebraic type classes * `kernel-laws`: The encoded laws for type classes defined in `kernel`, exported to assist third-party testing. * `free`: Free structures such as the free monad, and supporting type classes. * `tests`: Verifies the laws, and runs any other tests. Not published. - * `bench`: Benchmarking suites. Not published. + * `bench`: Benchmarking suites. Not published. As the type class families grow, it's possible that additional modules will be added as well. Modules which depend on other libraries diff --git a/alleycats-core/src/main/scala/alleycats/ConsK.scala b/alleycats-core/src/main/scala/alleycats/ConsK.scala index cb3621030f..d2ba4471b5 100644 --- a/alleycats-core/src/main/scala/alleycats/ConsK.scala +++ b/alleycats-core/src/main/scala/alleycats/ConsK.scala @@ -22,9 +22,8 @@ package alleycats import cats.SemigroupK -import simulacrum.typeclass -@typeclass trait ConsK[F[_]] extends Serializable { +trait ConsK[F[_]] extends Serializable { def cons[A](hd: A, tl: F[A]): F[A] } @@ -34,10 +33,6 @@ object ConsK { def cons[A](hd: A, tl: F[A]): F[A] = s.combineK(p.pure(hd), tl) } - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - /** * Summon an instance of [[ConsK]] for `F`. */ @@ -73,8 +68,4 @@ object ConsK { @deprecated("Use cats.syntax object imports", "2.2.0") object nonInheritedOps extends ToConsKOps - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - } diff --git a/alleycats-core/src/main/scala/alleycats/Empty.scala b/alleycats-core/src/main/scala/alleycats/Empty.scala index 0631dbebc1..7ae2bd74cc 100644 --- a/alleycats-core/src/main/scala/alleycats/Empty.scala +++ b/alleycats-core/src/main/scala/alleycats/Empty.scala @@ -24,9 +24,7 @@ package alleycats import cats.{Eq, Monoid} import cats.syntax.eq._ -import simulacrum.typeclass - -@typeclass trait Empty[A] extends Serializable { +trait Empty[A] extends Serializable { def empty: A def isEmpty(a: A)(implicit ev: Eq[A]): Boolean = @@ -42,10 +40,6 @@ object Empty extends EmptyInstances0 { def fromEmptyK[F[_], T](implicit ekf: EmptyK[F]): Empty[F[T]] = ekf.synthesize[T] - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - /** * Summon an instance of [[Empty]] for `A`. */ @@ -83,10 +77,6 @@ object Empty extends EmptyInstances0 { @deprecated("Use cats.syntax object imports", "2.2.0") object nonInheritedOps extends ToEmptyOps - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - } private[alleycats] trait EmptyInstances0 extends compat.IterableEmptyInstance with EmptyInstances1 diff --git a/alleycats-core/src/main/scala/alleycats/EmptyK.scala b/alleycats-core/src/main/scala/alleycats/EmptyK.scala index 3fa6eabbd6..314d1c6e78 100644 --- a/alleycats-core/src/main/scala/alleycats/EmptyK.scala +++ b/alleycats-core/src/main/scala/alleycats/EmptyK.scala @@ -21,9 +21,7 @@ package alleycats -import simulacrum.typeclass - -@typeclass trait EmptyK[F[_]] extends Serializable { self => +trait EmptyK[F[_]] extends Serializable { self => def empty[A]: F[A] def synthesize[A]: Empty[F[A]] = @@ -34,10 +32,6 @@ import simulacrum.typeclass object EmptyK extends EmptyKInstances0 { - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - /** * Summon an instance of [[EmptyK]] for `F`. */ @@ -73,10 +67,6 @@ object EmptyK extends EmptyKInstances0 { @deprecated("Use cats.syntax object imports", "2.2.0") object nonInheritedOps extends ToEmptyKOps - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - } private[alleycats] trait EmptyKInstances0 { diff --git a/alleycats-core/src/main/scala/alleycats/Extract.scala b/alleycats-core/src/main/scala/alleycats/Extract.scala index 2df7094fbb..26f12247c9 100644 --- a/alleycats-core/src/main/scala/alleycats/Extract.scala +++ b/alleycats-core/src/main/scala/alleycats/Extract.scala @@ -23,9 +23,7 @@ package alleycats import cats.{CoflatMap, Comonad} -import simulacrum.typeclass - -@typeclass trait Extract[F[_]] extends Serializable { +trait Extract[F[_]] extends Serializable { def extract[A](fa: F[A]): A } @@ -44,10 +42,6 @@ object Extract { def coflatMap[A, B](fa: F[A])(f: F[A] => B): F[B] = cf.coflatMap(fa)(f) } - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - /** * Summon an instance of [[Extract]] for `F`. */ @@ -84,8 +78,4 @@ object Extract { @deprecated("Use cats.syntax object imports", "2.2.0") object nonInheritedOps extends ToExtractOps - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - } diff --git a/alleycats-core/src/main/scala/alleycats/One.scala b/alleycats-core/src/main/scala/alleycats/One.scala index 78a54cfcca..471f5b1e80 100644 --- a/alleycats-core/src/main/scala/alleycats/One.scala +++ b/alleycats-core/src/main/scala/alleycats/One.scala @@ -23,9 +23,8 @@ package alleycats import cats.Eq import cats.syntax.eq._ -import simulacrum.typeclass -@typeclass trait One[A] extends Serializable { +trait One[A] extends Serializable { def one: A def isOne(a: A)(implicit ev: Eq[A]): Boolean = @@ -39,10 +38,6 @@ object One { def apply[A](a: => A): One[A] = new One[A] { lazy val one: A = a } - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - /** * Summon an instance of [[One]] for `A`. */ @@ -80,8 +75,4 @@ object One { @deprecated("Use cats.syntax object imports", "2.2.0") object nonInheritedOps extends ToOneOps - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - } diff --git a/alleycats-core/src/main/scala/alleycats/Pure.scala b/alleycats-core/src/main/scala/alleycats/Pure.scala index e5f2011f0e..bf57adc62a 100644 --- a/alleycats-core/src/main/scala/alleycats/Pure.scala +++ b/alleycats-core/src/main/scala/alleycats/Pure.scala @@ -22,9 +22,8 @@ package alleycats import cats.{Applicative, FlatMap, Monad} -import simulacrum.typeclass -@typeclass trait Pure[F[_]] extends Serializable { +trait Pure[F[_]] extends Serializable { def pure[A](a: A): F[A] } @@ -44,10 +43,6 @@ object Pure { def tailRecM[A, B](a: A)(f: (A) => F[Either[A, B]]): F[B] = fm.tailRecM(a)(f) } - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - /** * Summon an instance of [[Pure]] for `F`. */ @@ -83,8 +78,4 @@ object Pure { @deprecated("Use cats.syntax object imports", "2.2.0") object nonInheritedOps extends ToPureOps - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - } diff --git a/alleycats-core/src/main/scala/alleycats/Zero.scala b/alleycats-core/src/main/scala/alleycats/Zero.scala index fe4b5b52e1..b99febe172 100644 --- a/alleycats-core/src/main/scala/alleycats/Zero.scala +++ b/alleycats-core/src/main/scala/alleycats/Zero.scala @@ -24,9 +24,7 @@ package alleycats import cats.Eq import cats.syntax.eq._ -import simulacrum.typeclass - -@typeclass trait Zero[A] extends Serializable { +trait Zero[A] extends Serializable { def zero: A def isZero(a: A)(implicit ev: Eq[A]): Boolean = @@ -40,10 +38,6 @@ object Zero { def apply[A](a: => A): Zero[A] = new Zero[A] { lazy val zero: A = a } - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - /** * Summon an instance of [[Zero]] for `A`. */ @@ -81,8 +75,4 @@ object Zero { @deprecated("Use cats.syntax object imports", "2.2.0") object nonInheritedOps extends ToZeroOps - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - } diff --git a/build.sbt b/build.sbt index 3eec1efcd9..7f1285bf55 100644 --- a/build.sbt +++ b/build.sbt @@ -1,7 +1,5 @@ ThisBuild / tlBaseVersion := "2.8" -ThisBuild / scalafixDependencies += "org.typelevel" %% "simulacrum-scalafix" % "0.5.3" - val scalaCheckVersion = "1.15.4" val disciplineVersion = "1.4.0" @@ -60,15 +58,6 @@ lazy val cats1BincompatSettings = Seq( } ) -lazy val simulacrumSettings = Seq( - libraryDependencies ++= (if (tlIsScala3.value) Nil else Seq(compilerPlugin(scalafixSemanticdb))), - scalacOptions ++= ( - if (tlIsScala3.value) Nil - else Seq(s"-P:semanticdb:targetroot:${baseDirectory.value}/target/.semanticdb", "-Yrangepos") - ), - libraryDependencies += "org.typelevel" %% "simulacrum-scalafix-annotations" % "0.5.4" -) - ThisBuild / tlVersionIntroduced := Map("3" -> "2.6.1") lazy val commonJvmSettings = Seq( @@ -176,7 +165,7 @@ lazy val core = crossProject(JSPlatform, JVMPlatform, NativePlatform) .crossType(CrossType.Pure) .dependsOn(kernel) .settings(moduleName := "cats-core", name := "Cats core") - .settings(macroSettings, simulacrumSettings) + .settings(macroSettings) .settings(Compile / sourceGenerators += (Compile / sourceManaged).map(Boilerplate.gen).taskValue) .settings( libraryDependencies += "org.scalacheck" %%% "scalacheck" % scalaCheckVersion % Test, diff --git a/core/src/main/scala/cats/Align.scala b/core/src/main/scala/cats/Align.scala index 9c6eda47b0..cbb372d9e0 100644 --- a/core/src/main/scala/cats/Align.scala +++ b/core/src/main/scala/cats/Align.scala @@ -21,8 +21,6 @@ package cats -import simulacrum.typeclass - import cats.data.Ior import scala.collection.immutable.{Seq, SortedMap} @@ -32,7 +30,7 @@ import scala.collection.immutable.{Seq, SortedMap} * * Must obey the laws in cats.laws.AlignLaws */ -@typeclass trait Align[F[_]] extends Serializable { +trait Align[F[_]] extends Serializable { def functor: Functor[F] @@ -163,10 +161,6 @@ object Align extends ScalaVersionSpecificAlignInstances { ) } - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - /** * Summon an instance of [[Align]] for `F`. */ @@ -210,8 +204,4 @@ object Align extends ScalaVersionSpecificAlignInstances { @deprecated("Use cats.syntax object imports", "2.2.0") object nonInheritedOps extends ToAlignOps - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - } diff --git a/core/src/main/scala/cats/Alternative.scala b/core/src/main/scala/cats/Alternative.scala index 0361e442d4..0358bc9fa9 100644 --- a/core/src/main/scala/cats/Alternative.scala +++ b/core/src/main/scala/cats/Alternative.scala @@ -21,10 +21,9 @@ package cats -import simulacrum.typeclass import cats.kernel.compat.scalaVersionSpecific._ -@typeclass trait Alternative[F[_]] extends NonEmptyAlternative[F] with MonoidK[F] { self => +trait Alternative[F[_]] extends NonEmptyAlternative[F] with MonoidK[F] { self => // Note: `protected` is only necessary to enforce binary compatibility // since neither `private` nor `private[cats]` work properly here. @@ -79,7 +78,7 @@ import cats.kernel.compat.scalaVersionSpecific._ /** * Separate the inner foldable values into the "lefts" and "rights". - * + * * A variant of [[[separate[G[_,_],A,B](fgab:F[G[A,B]])(implicitFM:cats\.FlatMap[F]* separate]]] * that is specialized for Fs that have Foldable instances which allows for a single-pass implementation * (as opposed to {{{separate}}} which is 2-pass). @@ -132,10 +131,6 @@ import cats.kernel.compat.scalaVersionSpecific._ @suppressUnusedImportWarningForScalaVersionSpecific object Alternative { - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - /** * Summon an instance of [[Alternative]] for `F`. */ @@ -179,7 +174,4 @@ object Alternative { @deprecated("Use cats.syntax object imports", "2.2.0") object nonInheritedOps extends ToAlternativeOps - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ } diff --git a/core/src/main/scala/cats/Applicative.scala b/core/src/main/scala/cats/Applicative.scala index 1d8a44d3b6..33887665df 100644 --- a/core/src/main/scala/cats/Applicative.scala +++ b/core/src/main/scala/cats/Applicative.scala @@ -23,7 +23,7 @@ package cats import cats.arrow.Arrow import cats.data.Chain -import simulacrum.typeclass + import scala.collection.immutable.IndexedSeq /** @@ -36,7 +36,7 @@ import scala.collection.immutable.IndexedSeq * * Must obey the laws defined in cats.laws.ApplicativeLaws. */ -@typeclass trait Applicative[F[_]] extends Apply[F] with InvariantMonoidal[F] { self => +trait Applicative[F[_]] extends Apply[F] with InvariantMonoidal[F] { self => /** * `pure` lifts any value into the Applicative Functor. @@ -257,10 +257,6 @@ object Applicative { def map[A, B](fa: F[A])(f: A => B): F[B] = F.map(fa)(f) } - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - /** * Summon an instance of [[Applicative]] for `F`. */ @@ -298,10 +294,6 @@ object Applicative { @deprecated("Use cats.syntax object imports", "2.2.0") object nonInheritedOps extends ToApplicativeOps - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - } private[cats] class ApplicativeMonoid[F[_], A](f: Applicative[F], monoid: Monoid[A]) diff --git a/core/src/main/scala/cats/Apply.scala b/core/src/main/scala/cats/Apply.scala index 0c59f8ec1d..df9324bf49 100644 --- a/core/src/main/scala/cats/Apply.scala +++ b/core/src/main/scala/cats/Apply.scala @@ -21,7 +21,6 @@ package cats -import simulacrum.{noop, typeclass} import cats.data.Ior /** @@ -29,7 +28,6 @@ import cats.data.Ior * * Must obey the laws defined in cats.laws.ApplyLaws. */ -@typeclass(excludeParents = List("ApplyArityFunctions")) trait Apply[F[_]] extends Functor[F] with InvariantSemigroupal[F] with ApplyArityFunctions[F] { self => /** @@ -153,14 +151,14 @@ trait Apply[F[_]] extends Functor[F] with InvariantSemigroupal[F] with ApplyArit * Alias for [[productR]]. */ @deprecated("Use *> or productR instead.", "1.0.0-RC2") - @noop @inline final private[cats] def followedBy[A, B](fa: F[A])(fb: F[B]): F[B] = + @inline final private[cats] def followedBy[A, B](fa: F[A])(fb: F[B]): F[B] = productR(fa)(fb) /** * Alias for [[productL]]. */ @deprecated("Use <* or productL instead.", "1.0.0-RC2") - @noop @inline final private[cats] def forEffect[A, B](fa: F[A])(fb: F[B]): F[A] = + @inline final private[cats] def forEffect[A, B](fa: F[A])(fb: F[B]): F[A] = productL(fa)(fb) /** @@ -243,7 +241,6 @@ trait Apply[F[_]] extends Functor[F] with InvariantSemigroupal[F] with ApplyArit val G = Apply[G] } - @noop @deprecated("Dangerous method, use ifM (a flatMap) or ifF (a map) instead", "2.6.2") def ifA[A](fcond: F[Boolean])(ifTrue: F[A], ifFalse: F[A]): F[A] = { def ite(b: Boolean)(ifTrue: A, ifFalse: A) = if (b) ifTrue else ifFalse @@ -268,10 +265,6 @@ object Apply { def functor: Functor[F] = Apply[F] } - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - /** * Summon an instance of [[Apply]] for `F`. */ @@ -321,10 +314,6 @@ object Apply { @deprecated("Use cats.syntax object imports", "2.2.0") object nonInheritedOps extends ToApplyOps - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - } private[cats] class ApplySemigroup[F[_], A](f: Apply[F], sg: Semigroup[A]) extends Semigroup[F[A]] { diff --git a/core/src/main/scala/cats/Bifoldable.scala b/core/src/main/scala/cats/Bifoldable.scala index a87717464a..3e4bd8265a 100644 --- a/core/src/main/scala/cats/Bifoldable.scala +++ b/core/src/main/scala/cats/Bifoldable.scala @@ -21,12 +21,10 @@ package cats -import simulacrum.typeclass - /** * A type class abstracting over types that give rise to two independent [[cats.Foldable]]s. */ -@typeclass trait Bifoldable[F[_, _]] extends Serializable { self => +trait Bifoldable[F[_, _]] extends Serializable { self => /** * Collapse the structure with a left-associative function @@ -110,10 +108,6 @@ object Bifoldable extends cats.instances.NTupleBitraverseInstances { @deprecated("Use catsStdBitraverseForTuple2 in cats.instances.NTupleBitraverseInstances", "2.4.0") def catsBitraverseForTuple2: Bitraverse[Tuple2] = cats.instances.tuple.catsStdBitraverseForTuple2 - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - /** * Summon an instance of [[Bifoldable]] for `F`. */ @@ -155,10 +149,6 @@ object Bifoldable extends cats.instances.NTupleBitraverseInstances { @deprecated("Use cats.syntax object imports", "2.2.0") object nonInheritedOps extends ToBifoldableOps - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - } private[cats] trait ComposedBifoldable[F[_, _], G[_, _]] extends Bifoldable[λ[(α, β) => F[G[α, β], G[α, β]]]] { diff --git a/core/src/main/scala/cats/Bifunctor.scala b/core/src/main/scala/cats/Bifunctor.scala index 321bd97227..b187cd0499 100644 --- a/core/src/main/scala/cats/Bifunctor.scala +++ b/core/src/main/scala/cats/Bifunctor.scala @@ -20,13 +20,12 @@ */ package cats -import simulacrum.typeclass /** * A type class of types which give rise to two independent, covariant * functors. */ -@typeclass trait Bifunctor[F[_, _]] extends Serializable { self => +trait Bifunctor[F[_, _]] extends Serializable { self => /** * The quintessential method of the Bifunctor trait, it applies a @@ -84,10 +83,6 @@ object Bifunctor extends cats.instances.NTupleBifunctorInstances { @deprecated("Use catsStdBitraverseForTuple2 in cats.instances.NTupleBitraverseInstances", "2.4.0") def catsBifunctorForTuple2: Bifunctor[Tuple2] = cats.instances.tuple.catsStdBitraverseForTuple2 - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - /** * Summon an instance of [[Bifunctor]] for `F`. */ @@ -126,9 +121,6 @@ object Bifunctor extends cats.instances.NTupleBifunctorInstances { @deprecated("Use cats.syntax object imports", "2.2.0") object nonInheritedOps extends ToBifunctorOps - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ } private[cats] trait ComposedBifunctor[F[_, _], G[_, _]] extends Bifunctor[λ[(A, B) => F[G[A, B], G[A, B]]]] { diff --git a/core/src/main/scala/cats/Bimonad.scala b/core/src/main/scala/cats/Bimonad.scala index 8dd12825c0..bc6498cb35 100644 --- a/core/src/main/scala/cats/Bimonad.scala +++ b/core/src/main/scala/cats/Bimonad.scala @@ -21,16 +21,10 @@ package cats -import simulacrum.typeclass - -@typeclass trait Bimonad[F[_]] extends Monad[F] with Comonad[F] +trait Bimonad[F[_]] extends Monad[F] with Comonad[F] object Bimonad { - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - /** * Summon an instance of [[Bimonad]] for `F`. */ @@ -68,8 +62,4 @@ object Bimonad { @deprecated("Use cats.syntax object imports", "2.2.0") object nonInheritedOps extends ToBimonadOps - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - } diff --git a/core/src/main/scala/cats/Bitraverse.scala b/core/src/main/scala/cats/Bitraverse.scala index 6c10f2fa51..7da55b3258 100644 --- a/core/src/main/scala/cats/Bitraverse.scala +++ b/core/src/main/scala/cats/Bitraverse.scala @@ -21,12 +21,10 @@ package cats -import simulacrum.{noop, typeclass} - /** * A type class abstracting over types that give rise to two independent [[cats.Traverse]]s. */ -@typeclass trait Bitraverse[F[_, _]] extends Bifoldable[F] with Bifunctor[F] { self => +trait Bitraverse[F[_, _]] extends Bifoldable[F] with Bifunctor[F] { self => /** * Traverse each side of the structure with the given functions. @@ -102,7 +100,7 @@ import simulacrum.{noop, typeclass} * res2: Option[(Int, String)] = None * }}} */ - @noop + def leftTraverse[G[_], A, B, C](fab: F[A, B])(f: A => G[C])(implicit G: Applicative[G]): G[F[C, B]] = bitraverse(fab)(f, G.pure(_)) @@ -127,17 +125,13 @@ import simulacrum.{noop, typeclass} * res3: Option[Either[String,Int]] = None * }}} */ - @noop + def leftSequence[G[_], A, B](fgab: F[G[A], B])(implicit G: Applicative[G]): G[F[A, B]] = bitraverse(fgab)(identity, G.pure(_)) } object Bitraverse { - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - /** * Summon an instance of [[Bitraverse]] for `F`. */ @@ -179,10 +173,6 @@ object Bitraverse { @deprecated("Use cats.syntax object imports", "2.2.0") object nonInheritedOps extends ToBitraverseOps - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - } private[cats] trait ComposedBitraverse[F[_, _], G[_, _]] diff --git a/core/src/main/scala/cats/CoflatMap.scala b/core/src/main/scala/cats/CoflatMap.scala index 2395cbff75..b32a605694 100644 --- a/core/src/main/scala/cats/CoflatMap.scala +++ b/core/src/main/scala/cats/CoflatMap.scala @@ -21,14 +21,12 @@ package cats -import simulacrum.typeclass - /** * `CoflatMap` is the dual of `FlatMap`. * * Must obey the laws in cats.laws.CoflatMapLaws */ -@typeclass trait CoflatMap[F[_]] extends Functor[F] { +trait CoflatMap[F[_]] extends Functor[F] { /** * `coflatMap` is the dual of `flatMap` on `FlatMap`. It applies @@ -69,10 +67,6 @@ import simulacrum.typeclass object CoflatMap { - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - /** * Summon an instance of [[CoflatMap]] for `F`. */ @@ -112,8 +106,4 @@ object CoflatMap { @deprecated("Use cats.syntax object imports", "2.2.0") object nonInheritedOps extends ToCoflatMapOps - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - } diff --git a/core/src/main/scala/cats/CommutativeApplicative.scala b/core/src/main/scala/cats/CommutativeApplicative.scala index b2bcec2d5c..8f8a0dad2e 100644 --- a/core/src/main/scala/cats/CommutativeApplicative.scala +++ b/core/src/main/scala/cats/CommutativeApplicative.scala @@ -22,7 +22,6 @@ package cats import cats.kernel.CommutativeMonoid -import simulacrum.typeclass /** * Commutative Applicative. @@ -33,7 +32,7 @@ import simulacrum.typeclass * * Must obey the laws defined in cats.laws.CommutativeApplicativeLaws. */ -@typeclass trait CommutativeApplicative[F[_]] extends Applicative[F] with CommutativeApply[F] +trait CommutativeApplicative[F[_]] extends Applicative[F] with CommutativeApply[F] object CommutativeApplicative { def commutativeMonoidFor[F[_]: CommutativeApplicative, A: CommutativeMonoid]: CommutativeMonoid[F[A]] = @@ -47,10 +46,6 @@ object CommutativeApplicative { .map2(x, y)(CommutativeMonoid[A].combine) } - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - /** * Summon an instance of [[CommutativeApplicative]] for `F`. */ @@ -90,8 +85,4 @@ object CommutativeApplicative { @deprecated("Use cats.syntax object imports", "2.2.0") object nonInheritedOps extends ToCommutativeApplicativeOps - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - } diff --git a/core/src/main/scala/cats/CommutativeApply.scala b/core/src/main/scala/cats/CommutativeApply.scala index f0837c694e..52d3d75e56 100644 --- a/core/src/main/scala/cats/CommutativeApply.scala +++ b/core/src/main/scala/cats/CommutativeApply.scala @@ -22,7 +22,6 @@ package cats import cats.kernel.CommutativeSemigroup -import simulacrum.typeclass /** * Commutative Apply. @@ -33,7 +32,7 @@ import simulacrum.typeclass * * Must obey the laws defined in cats.laws.CommutativeApplyLaws. */ -@typeclass trait CommutativeApply[F[_]] extends Apply[F] +trait CommutativeApply[F[_]] extends Apply[F] object CommutativeApply { def commutativeSemigroupFor[F[_]: CommutativeApply, A: CommutativeSemigroup]: CommutativeSemigroup[F[A]] = @@ -43,10 +42,6 @@ object CommutativeApply { .map2(x, y)(CommutativeSemigroup[A].combine) } - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - /** * Summon an instance of [[CommutativeApply]] for `F`. */ @@ -84,8 +79,4 @@ object CommutativeApply { @deprecated("Use cats.syntax object imports", "2.2.0") object nonInheritedOps extends ToCommutativeApplyOps - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - } diff --git a/core/src/main/scala/cats/CommutativeFlatMap.scala b/core/src/main/scala/cats/CommutativeFlatMap.scala index df54832ee7..ed6f88f41c 100644 --- a/core/src/main/scala/cats/CommutativeFlatMap.scala +++ b/core/src/main/scala/cats/CommutativeFlatMap.scala @@ -21,8 +21,6 @@ package cats -import simulacrum.typeclass - /** * Commutative FlatMap. * @@ -32,14 +30,10 @@ import simulacrum.typeclass * * Must obey the laws defined in cats.laws.CommutativeFlatMapLaws. */ -@typeclass trait CommutativeFlatMap[F[_]] extends FlatMap[F] with CommutativeApply[F] +trait CommutativeFlatMap[F[_]] extends FlatMap[F] with CommutativeApply[F] object CommutativeFlatMap { - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - /** * Summon an instance of [[CommutativeFlatMap]] for `F`. */ @@ -77,8 +71,4 @@ object CommutativeFlatMap { @deprecated("Use cats.syntax object imports", "2.2.0") object nonInheritedOps extends ToCommutativeFlatMapOps - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - } diff --git a/core/src/main/scala/cats/CommutativeMonad.scala b/core/src/main/scala/cats/CommutativeMonad.scala index dae0821a89..a79b73c1bc 100644 --- a/core/src/main/scala/cats/CommutativeMonad.scala +++ b/core/src/main/scala/cats/CommutativeMonad.scala @@ -21,8 +21,6 @@ package cats -import simulacrum.typeclass - /** * Commutative Monad. * @@ -32,14 +30,10 @@ import simulacrum.typeclass * * Must obey the laws defined in cats.laws.CommutativeMonadLaws. */ -@typeclass trait CommutativeMonad[F[_]] extends Monad[F] with CommutativeFlatMap[F] with CommutativeApplicative[F] +trait CommutativeMonad[F[_]] extends Monad[F] with CommutativeFlatMap[F] with CommutativeApplicative[F] object CommutativeMonad { - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - /** * Summon an instance of [[CommutativeMonad]] for `F`. */ @@ -81,8 +75,4 @@ object CommutativeMonad { @deprecated("Use cats.syntax object imports", "2.2.0") object nonInheritedOps extends ToCommutativeMonadOps - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - } diff --git a/core/src/main/scala/cats/Comonad.scala b/core/src/main/scala/cats/Comonad.scala index c07aefd024..2db0275332 100644 --- a/core/src/main/scala/cats/Comonad.scala +++ b/core/src/main/scala/cats/Comonad.scala @@ -21,8 +21,6 @@ package cats -import simulacrum.typeclass - /** * Comonad * @@ -31,7 +29,7 @@ import simulacrum.typeclass * * Must obey the laws defined in cats.laws.ComonadLaws. */ -@typeclass trait Comonad[F[_]] extends CoflatMap[F] { +trait Comonad[F[_]] extends CoflatMap[F] { /** * `extract` is the dual of `pure` on Monad (via `Applicative`) @@ -51,10 +49,6 @@ import simulacrum.typeclass object Comonad { - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - /** * Summon an instance of [[Comonad]] for `F`. */ @@ -93,8 +87,4 @@ object Comonad { @deprecated("Use cats.syntax object imports", "2.2.0") object nonInheritedOps extends ToComonadOps - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - } diff --git a/core/src/main/scala/cats/Contravariant.scala b/core/src/main/scala/cats/Contravariant.scala index 7430501c61..1d7213a20e 100644 --- a/core/src/main/scala/cats/Contravariant.scala +++ b/core/src/main/scala/cats/Contravariant.scala @@ -20,12 +20,11 @@ */ package cats -import simulacrum.typeclass /** * Must obey the laws defined in cats.laws.ContravariantLaws. */ -@typeclass trait Contravariant[F[_]] extends Invariant[F] { self => +trait Contravariant[F[_]] extends Invariant[F] { self => def contramap[A, B](fa: F[A])(f: B => A): F[B] override def imap[A, B](fa: F[A])(f: A => B)(fi: B => A): F[B] = contramap(fa)(fi) @@ -52,10 +51,6 @@ import simulacrum.typeclass object Contravariant { - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - /** * Summon an instance of [[Contravariant]] for `F`. */ @@ -95,8 +90,4 @@ object Contravariant { @deprecated("Use cats.syntax object imports", "2.2.0") object nonInheritedOps extends ToContravariantOps - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - } diff --git a/core/src/main/scala/cats/ContravariantMonoidal.scala b/core/src/main/scala/cats/ContravariantMonoidal.scala index 7a20f83153..d534fe34bb 100644 --- a/core/src/main/scala/cats/ContravariantMonoidal.scala +++ b/core/src/main/scala/cats/ContravariantMonoidal.scala @@ -21,8 +21,6 @@ package cats -import simulacrum.typeclass - /** * [[ContravariantMonoidal]] functors are functors that supply * a unit along the diagonal map for the `contramap2` operation. @@ -32,7 +30,7 @@ import simulacrum.typeclass * Based on ekmett's contravariant library: * https://hackage.haskell.org/package/contravariant-1.4/docs/Data-Functor-Contravariant-Divisible.html */ -@typeclass trait ContravariantMonoidal[F[_]] extends ContravariantSemigroupal[F] with InvariantMonoidal[F] { +trait ContravariantMonoidal[F[_]] extends ContravariantSemigroupal[F] with InvariantMonoidal[F] { /** * `trivial` produces an instance of `F` for any type `A` @@ -46,10 +44,6 @@ object ContravariantMonoidal extends SemigroupalArityFunctions { def monoid[F[_], A](implicit f: ContravariantMonoidal[F]): Monoid[F[A]] = new ContravariantMonoidalMonoid[F, A](f) - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - /** * Summon an instance of [[ContravariantMonoidal]] for `F`. */ @@ -92,10 +86,6 @@ object ContravariantMonoidal extends SemigroupalArityFunctions { @deprecated("Use cats.syntax object imports", "2.2.0") object nonInheritedOps extends ToContravariantMonoidalOps - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - } private[cats] class ContravariantMonoidalMonoid[F[_], A](f: ContravariantMonoidal[F]) diff --git a/core/src/main/scala/cats/ContravariantSemigroupal.scala b/core/src/main/scala/cats/ContravariantSemigroupal.scala index 43f1969996..2b9d90e839 100644 --- a/core/src/main/scala/cats/ContravariantSemigroupal.scala +++ b/core/src/main/scala/cats/ContravariantSemigroupal.scala @@ -21,13 +21,11 @@ package cats -import simulacrum.typeclass - /** * [[ContravariantSemigroupal]] is nothing more than something both contravariant * and Semigroupal. It comes up enough to be useful, and composes well */ -@typeclass trait ContravariantSemigroupal[F[_]] extends InvariantSemigroupal[F] with Contravariant[F] { self => +trait ContravariantSemigroupal[F[_]] extends InvariantSemigroupal[F] with Contravariant[F] { self => override def composeFunctor[G[_]: Functor]: ContravariantSemigroupal[λ[α => F[G[α]]]] = new ComposedSemigroupal[F, G] { def F = self @@ -40,10 +38,6 @@ object ContravariantSemigroupal extends SemigroupalArityFunctions { def semigroup[F[_], A](implicit f: ContravariantSemigroupal[F]): Semigroup[F[A]] = new ContravariantSemigroupalSemigroup[F, A](f) - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - /** * Summon an instance of [[ContravariantSemigroupal]] for `F`. */ @@ -85,10 +79,6 @@ object ContravariantSemigroupal extends SemigroupalArityFunctions { @deprecated("Use cats.syntax object imports", "2.2.0") object nonInheritedOps extends ToContravariantSemigroupalOps - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - } private[cats] class ContravariantSemigroupalSemigroup[F[_], A](f: ContravariantSemigroupal[F]) extends Semigroup[F[A]] { diff --git a/core/src/main/scala/cats/Distributive.scala b/core/src/main/scala/cats/Distributive.scala index 7390ea0326..aca048e75a 100644 --- a/core/src/main/scala/cats/Distributive.scala +++ b/core/src/main/scala/cats/Distributive.scala @@ -20,9 +20,8 @@ */ package cats -import simulacrum.typeclass -@typeclass trait Distributive[F[_]] extends Functor[F] { self => +trait Distributive[F[_]] extends Functor[F] { self => /** * Given a function which returns a distributive `F`, apply that value across the structure G. @@ -44,10 +43,6 @@ import simulacrum.typeclass object Distributive { - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - /** * Summon an instance of [[Distributive]] for `F`. */ @@ -85,8 +80,4 @@ object Distributive { @deprecated("Use cats.syntax object imports", "2.2.0") object nonInheritedOps extends ToDistributiveOps - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - } diff --git a/core/src/main/scala/cats/FlatMap.scala b/core/src/main/scala/cats/FlatMap.scala index fd24549e05..fe087077d3 100644 --- a/core/src/main/scala/cats/FlatMap.scala +++ b/core/src/main/scala/cats/FlatMap.scala @@ -21,9 +21,6 @@ package cats -import simulacrum.typeclass -import simulacrum.noop - /** * FlatMap type class gives us flatMap, which allows us to have a value * in a context (F[A]) and then feed that into a function that takes @@ -39,7 +36,7 @@ import simulacrum.noop * * Must obey the laws defined in cats.laws.FlatMapLaws. */ -@typeclass trait FlatMap[F[_]] extends Apply[F] { +trait FlatMap[F[_]] extends Apply[F] { def flatMap[A, B](fa: F[A])(f: A => F[B]): F[B] /** @@ -78,7 +75,7 @@ import simulacrum.noop def productREval[A, B](fa: F[A])(fb: Eval[F[B]]): F[B] = flatMap(fa)(_ => fb.value) @deprecated("Use productREval instead.", "1.0.0-RC2") - @noop private[cats] def followedByEval[A, B](fa: F[A])(fb: Eval[F[B]]): F[B] = productREval(fa)(fb) + private[cats] def followedByEval[A, B](fa: F[A])(fb: Eval[F[B]]): F[B] = productREval(fa)(fb) /** * Sequentially compose two actions, discarding any value produced by the second. This variant of @@ -102,7 +99,7 @@ import simulacrum.noop def productLEval[A, B](fa: F[A])(fb: Eval[F[B]]): F[A] = flatMap(fa)(a => as(fb.value, a)) @deprecated("Use productLEval instead.", "1.0.0-RC2") - @noop private[cats] def forEffectEval[A, B](fa: F[A])(fb: Eval[F[B]]): F[A] = productLEval(fa)(fb) + private[cats] def forEffectEval[A, B](fa: F[A])(fb: Eval[F[B]]): F[A] = productLEval(fa)(fb) override def ap[A, B](ff: F[A => B])(fa: F[A]): F[B] = flatMap(ff)(f => map(fa)(f)) @@ -141,7 +138,7 @@ import simulacrum.noop /** * `if` lifted into monad. */ - @noop + def ifM[B](fa: F[Boolean])(ifTrue: => F[B], ifFalse: => F[B]): F[B] = flatMap(fa)(if (_) ifTrue else ifFalse) @@ -187,7 +184,7 @@ import simulacrum.noop * allocating single element lists, but if we have a k > 1, we will allocate * exponentially increasing memory and very quickly OOM. */ - @noop + def foreverM[A, B](fa: F[A]): F[B] = { // allocate two things once for efficiency. val leftUnit = Left(()) @@ -200,7 +197,7 @@ import simulacrum.noop * A may be some state, we may take the current state, run some effect to get * a new state and repeat. */ - @noop + def iterateForeverM[A, B](a: A)(f: A => F[A]): F[B] = tailRecM[A, B](a)(f.andThen { fa => map(fa)(Left(_): Either[A, B]) @@ -211,7 +208,7 @@ import simulacrum.noop * for polling type operations on State (or RNG) Monads, or in effect * monads. */ - @noop + def untilDefinedM[A](foa: F[Option[A]]): F[A] = { val leftUnit: Either[Unit, A] = Left(()) val feither: F[Either[Unit, A]] = map(foa) { @@ -224,10 +221,6 @@ import simulacrum.noop object FlatMap { - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - /** * Summon an instance of [[FlatMap]] for `F`. */ @@ -271,8 +264,4 @@ object FlatMap { @deprecated("Use cats.syntax object imports", "2.2.0") object nonInheritedOps extends ToFlatMapOps - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - } diff --git a/core/src/main/scala/cats/Foldable.scala b/core/src/main/scala/cats/Foldable.scala index 01cd784428..3392031344 100644 --- a/core/src/main/scala/cats/Foldable.scala +++ b/core/src/main/scala/cats/Foldable.scala @@ -23,7 +23,7 @@ package cats import scala.collection.mutable import cats.kernel.CommutativeMonoid -import simulacrum.{noop, typeclass} + import Foldable.{sentinel, Source} /** @@ -48,7 +48,6 @@ import Foldable.{sentinel, Source} * * See: [[http://www.cs.nott.ac.uk/~pszgmh/fold.pdf A tutorial on the universality and expressiveness of fold]] */ -@typeclass(excludeParents = List("FoldableNFunctions")) trait Foldable[F[_]] extends UnorderedFoldable[F] with FoldableNFunctions[F] { self => /** @@ -389,7 +388,7 @@ trait Foldable[F[_]] extends UnorderedFoldable[F] with FoldableNFunctions[F] { s * res3: scala.util.Either[String,Option[String]] = Right(Some(Four)) * }}} */ - @noop + def collectFirstSomeM[G[_], A, B](fa: F[A])(f: A => G[Option[B]])(implicit G: Monad[G]): G[Option[B]] = G.tailRecM(Foldable.Source.fromFoldable(fa)(self))(_.uncons match { case Some((a, src)) => @@ -409,7 +408,7 @@ trait Foldable[F[_]] extends UnorderedFoldable[F] with FoldableNFunctions[F] { s * res0: Int = 6 * }}} */ - @noop + def collectFold[A, B](fa: F[A])(f: PartialFunction[A, B])(implicit B: Monoid[B]): B = foldLeft(fa, B.empty)((acc, a) => B.combine(acc, f.applyOrElse(a, (_: A) => B.empty))) @@ -497,10 +496,8 @@ trait Foldable[F[_]] extends UnorderedFoldable[F] with FoldableNFunctions[F] { s * scala> F.foldA(List(Either.right[String, Int](1), Either.right[String, Int](2))) * res0: Either[String, Int] = Right(3) * }}} - * - * See [[https://github.com/typelevel/simulacrum/issues/162 this issue]] for an explanation of `@noop` usage. */ - @noop def foldA[G[_], A](fga: F[G[A]])(implicit G: Applicative[G], A: Monoid[A]): G[A] = + def foldA[G[_], A](fga: F[G[A]])(implicit G: Applicative[G], A: Monoid[A]): G[A] = foldMapA(fga)(identity) /** @@ -515,7 +512,7 @@ trait Foldable[F[_]] extends UnorderedFoldable[F] with FoldableNFunctions[F] { s * a: String = "foo321" * }}} */ - @noop + def foldMapK[G[_], A, B](fa: F[A])(f: A => G[B])(implicit G: MonoidK[G]): G[B] = foldRight(fa, Eval.now(G.empty[B])) { (a, evalGb) => G.combineKEval(f(a), evalGb) @@ -665,7 +662,7 @@ trait Foldable[F[_]] extends UnorderedFoldable[F] with FoldableNFunctions[F] { s * res3: Either[String,Option[Int]] = Left(error) * }}} */ - @noop + def findM[G[_], A](fa: F[A])(p: A => G[Boolean])(implicit G: Monad[G]): G[Option[A]] = G.tailRecM(Foldable.Source.fromFoldable(fa)(self))(_.uncons match { case Some((a, src)) => G.map(p(a))(if (_) Right(Some(a)) else Left(src.value)) @@ -882,7 +879,7 @@ trait Foldable[F[_]] extends UnorderedFoldable[F] with FoldableNFunctions[F] { s * res1: (List[Int], List[Nothing with Any]) = (List(1, 2, 3, 4),List()) * }}} */ - @noop + def partitionBifold[H[_, _], A, B, C]( fa: F[A] )(f: A => H[B, C])(implicit A: Alternative[F], H: Bifoldable[H]): (F[B], F[C]) = { @@ -908,7 +905,7 @@ trait Foldable[F[_]] extends UnorderedFoldable[F] with FoldableNFunctions[F] { s * res0: Option[(List[Int], List[Nothing with Any])] = Some((List(1, 2, 3, 4),List())) * }}} */ - @noop + def partitionBifoldM[G[_], H[_, _], A, B, C]( fa: F[A] )(f: A => G[H[B, C]])(implicit A: Alternative[F], M: Monad[G], H: Bifoldable[H]): G[(F[B], F[C])] = { @@ -940,7 +937,7 @@ trait Foldable[F[_]] extends UnorderedFoldable[F] with FoldableNFunctions[F] { s * res1: (List[Nothing], List[Int]) = (List(),List(4, 8, 12, 16)) * }}} */ - @noop + def partitionEitherM[G[_], A, B, C]( fa: F[A] )(f: A => G[Either[B, C]])(implicit A: Alternative[F], M: Monad[G]): G[(F[B], F[C])] = { @@ -994,10 +991,6 @@ object Foldable { F.foldRight[A, Source[A]](fa, Now(Empty))((a, evalSrc) => Later(cons(a, evalSrc))).value } - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - /** * Summon an instance of [[Foldable]] for `F`. */ @@ -1093,8 +1086,4 @@ object Foldable { @deprecated("Use cats.syntax object imports", "2.2.0") object nonInheritedOps extends ToFoldableOps - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - } diff --git a/core/src/main/scala/cats/Functor.scala b/core/src/main/scala/cats/Functor.scala index c9f7558a00..49f1ed6f59 100644 --- a/core/src/main/scala/cats/Functor.scala +++ b/core/src/main/scala/cats/Functor.scala @@ -21,8 +21,6 @@ package cats -import simulacrum.{noop, typeclass} - /** * Functor. * @@ -30,7 +28,7 @@ import simulacrum.{noop, typeclass} * * Must obey the laws defined in cats.laws.FunctorLaws. */ -@typeclass trait Functor[F[_]] extends Invariant[F] { self => +trait Functor[F[_]] extends Invariant[F] { self => def map[A, B](fa: F[A])(f: A => B): F[B] override def imap[A, B](fa: F[A])(f: A => B)(g: B => A): F[B] = map(fa)(f) @@ -192,7 +190,7 @@ import simulacrum.{noop, typeclass} * res0: (List[Int], List[Int]) = (List(1, 3),List(2, 4)) * }}} */ - @noop + def unzip[A, B](fab: F[(A, B)]): (F[A], F[B]) = (map(fab)(_._1), map(fab)(_._2)) /** @@ -207,7 +205,7 @@ import simulacrum.{noop, typeclass} * res0: List[Int] = List(1, 0, 0) * }}} */ - @noop + def ifF[A](fb: F[Boolean])(ifTrue: => A, ifFalse: => A): F[A] = map(fb)(x => if (x) ifTrue else ifFalse) def compose[G[_]: Functor]: Functor[λ[α => F[G[α]]]] = @@ -225,10 +223,6 @@ import simulacrum.{noop, typeclass} object Functor { - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - /** * Summon an instance of [[Functor]] for `F`. */ @@ -275,8 +269,4 @@ object Functor { @deprecated("Use cats.syntax object imports", "2.2.0") object nonInheritedOps extends ToFunctorOps - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - } diff --git a/core/src/main/scala/cats/FunctorFilter.scala b/core/src/main/scala/cats/FunctorFilter.scala index 32435f03d4..e3363bac12 100644 --- a/core/src/main/scala/cats/FunctorFilter.scala +++ b/core/src/main/scala/cats/FunctorFilter.scala @@ -22,12 +22,11 @@ package cats import scala.collection.immutable.{Queue, Seq, SortedMap} -import simulacrum.typeclass /** * `FunctorFilter[F]` allows you to `map` and filter out elements simultaneously. */ -@typeclass + trait FunctorFilter[F[_]] extends Serializable { def functor: Functor[F] @@ -110,10 +109,6 @@ object FunctorFilter extends ScalaVersionSpecificTraverseFilterInstances with Fu implicit def catsTraverseFilterForQueue: TraverseFilter[Queue] = cats.instances.queue.catsStdTraverseFilterForQueue - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - /** * Summon an instance of [[FunctorFilter]] for `F`. */ @@ -155,10 +150,6 @@ object FunctorFilter extends ScalaVersionSpecificTraverseFilterInstances with Fu @deprecated("Use cats.syntax object imports", "2.2.0") object nonInheritedOps extends ToFunctorFilterOps - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - } trait FunctorFilterInstances0 { diff --git a/core/src/main/scala/cats/Invariant.scala b/core/src/main/scala/cats/Invariant.scala index 654b45630b..4863fe6b2f 100644 --- a/core/src/main/scala/cats/Invariant.scala +++ b/core/src/main/scala/cats/Invariant.scala @@ -23,7 +23,7 @@ package cats import cats.arrow.Arrow import cats.kernel._ -import simulacrum.typeclass + import cats.kernel.compat.scalaVersionSpecific._ import scala.collection.immutable.{Queue, Seq, SortedMap} import scala.concurrent.{ExecutionContext, Future} @@ -33,7 +33,7 @@ import scala.util.control.TailCalls.TailRec /** * Must obey the laws defined in cats.laws.InvariantLaws. */ -@typeclass trait Invariant[F[_]] extends Serializable { self => +trait Invariant[F[_]] extends Serializable { self => /** * Transform an `F[A]` into an `F[B]` by providing a transformation from `A` @@ -271,10 +271,6 @@ object Invariant extends ScalaVersionSpecificInvariantInstances with InvariantIn @deprecated("Use catsStdInstancesForTuple2 in cats.instances.NTupleMonadInstances", "2.4.0") def catsComonadForTuple2[A]: Comonad[(A, *)] = cats.instances.tuple.catsStdInstancesForTuple2[A] - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - /** * Summon an instance of [[Invariant]] for `F`. */ @@ -311,10 +307,6 @@ object Invariant extends ScalaVersionSpecificInvariantInstances with InvariantIn @deprecated("Use cats.syntax object imports", "2.2.0") object nonInheritedOps extends ToInvariantOps - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - } private[cats] trait InvariantInstances0 extends InvariantInstances1 { diff --git a/core/src/main/scala/cats/InvariantMonoidal.scala b/core/src/main/scala/cats/InvariantMonoidal.scala index 2489fbce45..15f4bc91ab 100644 --- a/core/src/main/scala/cats/InvariantMonoidal.scala +++ b/core/src/main/scala/cats/InvariantMonoidal.scala @@ -21,14 +21,12 @@ package cats -import simulacrum.typeclass - /** * Invariant version of a Monoidal. * * Must obey the laws defined in cats.laws.InvariantMonoidalLaws. */ -@typeclass trait InvariantMonoidal[F[_]] extends InvariantSemigroupal[F] { +trait InvariantMonoidal[F[_]] extends InvariantSemigroupal[F] { /** * `point` lifts any value into a Monoidal Functor. @@ -55,10 +53,6 @@ object InvariantMonoidal { def monoid[F[_], A](implicit F: InvariantMonoidal[F], A: Monoid[A]): Monoid[F[A]] = new InvariantMonoidalMonoid[F, A](F, A) - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - /** * Summon an instance of [[InvariantMonoidal]] for `F`. */ @@ -96,10 +90,6 @@ object InvariantMonoidal { @deprecated("Use cats.syntax object imports", "2.2.0") object nonInheritedOps extends ToInvariantMonoidalOps - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - } private[cats] class InvariantMonoidalMonoid[F[_], A](f: InvariantMonoidal[F], monoid: Monoid[A]) diff --git a/core/src/main/scala/cats/InvariantSemigroupal.scala b/core/src/main/scala/cats/InvariantSemigroupal.scala index 89ea9197a6..dc504363d3 100644 --- a/core/src/main/scala/cats/InvariantSemigroupal.scala +++ b/core/src/main/scala/cats/InvariantSemigroupal.scala @@ -21,13 +21,11 @@ package cats -import simulacrum.typeclass - /** * [[InvariantSemigroupal]] is nothing more than something both invariant * and Semigroupal. It comes up enough to be useful, and composes well */ -@typeclass trait InvariantSemigroupal[F[_]] extends Semigroupal[F] with Invariant[F] { self => +trait InvariantSemigroupal[F[_]] extends Semigroupal[F] with Invariant[F] { self => def composeApply[G[_]: Apply]: InvariantSemigroupal[λ[α => F[G[α]]]] = new ComposedInvariantApplySemigroupal[F, G] { @@ -45,10 +43,6 @@ object InvariantSemigroupal extends SemigroupalArityFunctions { def semigroup[F[_], A](implicit F: InvariantSemigroupal[F], A: Semigroup[A]): Semigroup[F[A]] = new InvariantSemigroupalSemigroup[F, A](F, A) - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - /** * Summon an instance of [[InvariantSemigroupal]] for `F`. */ @@ -88,10 +82,6 @@ object InvariantSemigroupal extends SemigroupalArityFunctions { @deprecated("Use cats.syntax object imports", "2.2.0") object nonInheritedOps extends ToInvariantSemigroupalOps - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - } private[cats] class InvariantSemigroupalSemigroup[F[_], A](f: InvariantSemigroupal[F], sg: Semigroup[A]) diff --git a/core/src/main/scala/cats/Monad.scala b/core/src/main/scala/cats/Monad.scala index 6e050d4e99..c212fc7038 100644 --- a/core/src/main/scala/cats/Monad.scala +++ b/core/src/main/scala/cats/Monad.scala @@ -21,8 +21,6 @@ package cats -import simulacrum.{noop, typeclass} - /** * Monad. * @@ -32,7 +30,7 @@ import simulacrum.{noop, typeclass} * * Must obey the laws defined in cats.laws.MonadLaws. */ -@typeclass trait Monad[F[_]] extends FlatMap[F] with Applicative[F] { +trait Monad[F[_]] extends FlatMap[F] with Applicative[F] { override def map[A, B](fa: F[A])(f: A => B): F[B] = flatMap(fa)(a => pure(f(a))) @@ -43,7 +41,7 @@ import simulacrum.{noop, typeclass} * This implementation uses append on each evaluation result, * so avoid data structures with non-constant append performance, e.g. `List`. */ - @noop + def whileM[G[_], A](p: F[Boolean])(body: => F[A])(implicit G: Alternative[G]): F[G[A]] = { val b = Eval.later(body) tailRecM[G[A], G[A]](G.empty)(xs => @@ -63,7 +61,7 @@ import simulacrum.{noop, typeclass} * returns `true`. The condition is evaluated before the loop body. * Discards results. */ - @noop + def whileM_[A](p: F[Boolean])(body: => F[A]): F[Unit] = { val continue: Either[Unit, Unit] = Left(()) val stop: F[Either[Unit, Unit]] = pure(Right(())) @@ -149,7 +147,7 @@ import simulacrum.{noop, typeclass} * [[https://github.com/typelevel/cats/pull/3553#discussion_r468121480 implementation]] due to P. Oscar Boykin * @see See [[https://gitter.im/typelevel/cats-effect?at=5f297e4314c413356f56d230]] for the discussion. */ - @noop + def ifElseM[A](branches: (F[Boolean], F[A])*)(els: F[A]): F[A] = { type Branches = List[(F[Boolean], F[A])] @@ -167,10 +165,6 @@ import simulacrum.{noop, typeclass} object Monad { - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - /** * Summon an instance of [[Monad]] for `F`. */ @@ -213,8 +207,4 @@ object Monad { @deprecated("Use cats.syntax object imports", "2.2.0") object nonInheritedOps extends ToMonadOps - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - } diff --git a/core/src/main/scala/cats/MonoidK.scala b/core/src/main/scala/cats/MonoidK.scala index dd56a3ad3b..92fd112a1e 100644 --- a/core/src/main/scala/cats/MonoidK.scala +++ b/core/src/main/scala/cats/MonoidK.scala @@ -23,8 +23,6 @@ package cats import cats.kernel.compat.scalaVersionSpecific._ -import simulacrum.typeclass - /** * MonoidK is a universal monoid which operates on kinds. * @@ -45,7 +43,7 @@ import simulacrum.typeclass * combination operation and empty value just depend on the * structure of F, but not on the structure of A. */ -@typeclass trait MonoidK[F[_]] extends SemigroupK[F] { self => +trait MonoidK[F[_]] extends SemigroupK[F] { self => /** * Given a type A, create an "empty" F[A] value. @@ -155,10 +153,6 @@ import simulacrum.typeclass @suppressUnusedImportWarningForScalaVersionSpecific object MonoidK { - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - /** * Summon an instance of [[MonoidK]] for `F`. */ @@ -196,8 +190,4 @@ object MonoidK { @deprecated("Use cats.syntax object imports", "2.2.0") object nonInheritedOps extends ToMonoidKOps - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - } diff --git a/core/src/main/scala/cats/NonEmptyAlternative.scala b/core/src/main/scala/cats/NonEmptyAlternative.scala index 75891de55a..a5d846c30f 100644 --- a/core/src/main/scala/cats/NonEmptyAlternative.scala +++ b/core/src/main/scala/cats/NonEmptyAlternative.scala @@ -21,9 +21,7 @@ package cats -import simulacrum.typeclass - -@typeclass trait NonEmptyAlternative[F[_]] extends Applicative[F] with SemigroupK[F] { self => +trait NonEmptyAlternative[F[_]] extends Applicative[F] with SemigroupK[F] { self => /** * Lift `a` into `F[_]` and prepend it to `fa`. @@ -55,9 +53,6 @@ import simulacrum.typeclass } object NonEmptyAlternative { - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ /** * Summon an instance of [[NonEmptyAlternative]] for `F`. @@ -78,8 +73,7 @@ object NonEmptyAlternative { type TypeClassType <: NonEmptyAlternative[F] def self: F[A] val typeClassInstance: TypeClassType - // Note: `prependK` has to be added manually since simulacrum is not able to handle `self` as a second parameter. - // def prependK(a: A): F[A] = typeClassInstance.prependK[A](a, self) + def prependK(a: A): F[A] = typeClassInstance.prependK[A](a, self) def appendK(a: A): F[A] = typeClassInstance.appendK[A](self, a) } trait AllOps[F[_], A] extends Ops[F, A] with Applicative.AllOps[F, A] with SemigroupK.AllOps[F, A] { @@ -97,7 +91,4 @@ object NonEmptyAlternative { @deprecated("Use cats.syntax object imports", "2.2.0") object nonInheritedOps extends ToNonEmptyAlternativeOps - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ } diff --git a/core/src/main/scala/cats/NonEmptyTraverse.scala b/core/src/main/scala/cats/NonEmptyTraverse.scala index a182ec9713..eb1983b635 100644 --- a/core/src/main/scala/cats/NonEmptyTraverse.scala +++ b/core/src/main/scala/cats/NonEmptyTraverse.scala @@ -21,15 +21,13 @@ package cats -import simulacrum.typeclass - /** * NonEmptyTraverse, also known as Traversable1. * * `NonEmptyTraverse` is like a non-empty `Traverse`. In addition to the traverse and sequence * methods it provides nonEmptyTraverse and nonEmptySequence methods which require an `Apply` instance instead of `Applicative`. */ -@typeclass trait NonEmptyTraverse[F[_]] extends Traverse[F] with Reducible[F] { self => +trait NonEmptyTraverse[F[_]] extends Traverse[F] with Reducible[F] { self => /** * Given a function which returns a G effect, thread this effect @@ -117,10 +115,6 @@ import simulacrum.typeclass object NonEmptyTraverse { - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - /** * Summon an instance of [[NonEmptyTraverse]] for `F`. */ @@ -166,8 +160,4 @@ object NonEmptyTraverse { @deprecated("Use cats.syntax object imports", "2.2.0") object nonInheritedOps extends ToNonEmptyTraverseOps - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - } diff --git a/core/src/main/scala/cats/Reducible.scala b/core/src/main/scala/cats/Reducible.scala index 488d018120..18bdedd02c 100644 --- a/core/src/main/scala/cats/Reducible.scala +++ b/core/src/main/scala/cats/Reducible.scala @@ -23,7 +23,6 @@ package cats import cats.Foldable.Source import cats.data.{Ior, NonEmptyList} -import simulacrum.{noop, typeclass} /** * Data structures that can be reduced to a summary value. @@ -38,7 +37,7 @@ import simulacrum.{noop, typeclass} * - `reduceLeftTo(fa)(f)(g)` eagerly reduces with an additional mapping function * - `reduceRightTo(fa)(f)(g)` lazily reduces with an additional mapping function */ -@typeclass trait Reducible[F[_]] extends Foldable[F] { self => +trait Reducible[F[_]] extends Foldable[F] { self => /** * Left-associative reduction on `F` using the function `f`. @@ -106,7 +105,7 @@ import simulacrum.{noop, typeclass} * a: String = "foo321" * }}} */ - @noop + def reduceMapK[G[_], A, B](fa: F[A])(f: A => G[B])(implicit G: SemigroupK[G]): G[B] = reduceLeftTo(fa)(f)((b, a) => G.combineK(b, f(a))) @@ -127,10 +126,8 @@ import simulacrum.{noop, typeclass} * semigroup for `G[_]`. * * This method is similar to [[reduce]], but may short-circuit. - * - * See [[https://github.com/typelevel/simulacrum/issues/162 this issue]] for an explanation of `@noop` usage. */ - @noop def reduceA[G[_], A](fga: F[G[A]])(implicit G: Apply[G], A: Semigroup[A]): G[A] = + def reduceA[G[_], A](fga: F[G[A]])(implicit G: Apply[G], A: Semigroup[A]): G[A] = reduceMapA(fga)(identity) /** @@ -367,10 +364,6 @@ import simulacrum.{noop, typeclass} object Reducible { - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - /** * Summon an instance of [[Reducible]] for `F`. */ @@ -441,10 +434,6 @@ object Reducible { @deprecated("Use cats.syntax object imports", "2.2.0") object nonInheritedOps extends ToReducibleOps - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - } /** diff --git a/core/src/main/scala/cats/SemigroupK.scala b/core/src/main/scala/cats/SemigroupK.scala index 0990010462..01e2340410 100644 --- a/core/src/main/scala/cats/SemigroupK.scala +++ b/core/src/main/scala/cats/SemigroupK.scala @@ -23,7 +23,7 @@ package cats import scala.annotation.tailrec import scala.collection.immutable.{Seq, SortedMap, SortedSet} -import simulacrum.typeclass + import cats.data.Ior import cats.kernel.compat.scalaVersionSpecific._ @@ -45,7 +45,7 @@ import cats.kernel.compat.scalaVersionSpecific._ * The combination operation just depends on the structure of F, * but not the structure of A. */ -@typeclass trait SemigroupK[F[_]] extends Serializable { self => +trait SemigroupK[F[_]] extends Serializable { self => /** * Combine two F[A] values. @@ -57,7 +57,7 @@ import cats.kernel.compat.scalaVersionSpecific._ * res0: List[Int] = List(1, 2, 3, 4) * }}} */ - @simulacrum.op("<+>", alias = true) + def combineK[A](x: F[A], y: F[A]): F[A] /** @@ -213,10 +213,6 @@ object SemigroupK extends ScalaVersionSpecificMonoidKInstances with SemigroupKIn cats.instances.sortedMap.catsStdMonoidKForSortedMap[K] implicit def catsMonoidKForEndo: MonoidK[Endo] = cats.instances.function.catsStdMonoidKForFunction1 - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - /** * Summon an instance of [[SemigroupK]] for `F`. */ @@ -256,10 +252,6 @@ object SemigroupK extends ScalaVersionSpecificMonoidKInstances with SemigroupKIn @deprecated("Use cats.syntax object imports", "2.2.0") object nonInheritedOps extends ToSemigroupKOps - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - } trait SemigroupKInstances0 { diff --git a/core/src/main/scala/cats/Semigroupal.scala b/core/src/main/scala/cats/Semigroupal.scala index 0255a5f06b..8151cd3d33 100644 --- a/core/src/main/scala/cats/Semigroupal.scala +++ b/core/src/main/scala/cats/Semigroupal.scala @@ -25,7 +25,6 @@ import cats.kernel.CommutativeSemigroup import scala.collection.immutable.{Queue, Seq, SortedMap, SortedSet} import scala.concurrent.{ExecutionContext, Future} import scala.util.Try -import simulacrum.typeclass /** * [[Semigroupal]] captures the idea of composing independent effectful values. @@ -37,7 +36,7 @@ import simulacrum.typeclass * That same idea is also manifested in the form of [[Apply]], and indeed [[Apply]] extends both * [[Semigroupal]] and [[Functor]] to illustrate this. */ -@typeclass trait Semigroupal[F[_]] extends Serializable { +trait Semigroupal[F[_]] extends Serializable { /** * Combine an `F[A]` and an `F[B]` into an `F[(A, B)]` that maintains the effects of both `fa` and `fb`. @@ -108,10 +107,6 @@ object Semigroupal extends ScalaVersionSpecificSemigroupalInstances with Semigro implicit val catsSemigroupalForCommutativeSemigroup: Semigroupal[CommutativeSemigroup] = cats.instances.invariant.catsInvariantMonoidalCommutativeSemigroup - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - /** * Summon an instance of [[Semigroupal]] for `F`. */ @@ -148,8 +143,4 @@ object Semigroupal extends ScalaVersionSpecificSemigroupalInstances with Semigro @deprecated("Use cats.syntax object imports", "2.2.0") object nonInheritedOps extends ToSemigroupalOps - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - } diff --git a/core/src/main/scala/cats/Traverse.scala b/core/src/main/scala/cats/Traverse.scala index b380f15229..1d86d7fc93 100644 --- a/core/src/main/scala/cats/Traverse.scala +++ b/core/src/main/scala/cats/Traverse.scala @@ -24,8 +24,6 @@ package cats import cats.data.State import cats.data.StateT -import simulacrum.typeclass - /** * Traverse, also known as Traversable. * @@ -37,7 +35,7 @@ import simulacrum.typeclass * * See: [[https://www.cs.ox.ac.uk/jeremy.gibbons/publications/iterator.pdf The Essence of the Iterator Pattern]] */ -@typeclass trait Traverse[F[_]] extends Functor[F] with Foldable[F] with UnorderedTraverse[F] { self => +trait Traverse[F[_]] extends Functor[F] with Foldable[F] with UnorderedTraverse[F] { self => /** * Given a function which returns a G effect, thread this effect @@ -172,10 +170,6 @@ import simulacrum.typeclass object Traverse { - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - /** * Summon an instance of [[Traverse]] for `F`. */ @@ -231,8 +225,4 @@ object Traverse { @deprecated("Use cats.syntax object imports", "2.2.0") object nonInheritedOps extends ToTraverseOps - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - } diff --git a/core/src/main/scala/cats/TraverseFilter.scala b/core/src/main/scala/cats/TraverseFilter.scala index 76628ac408..3d0dae6ae6 100644 --- a/core/src/main/scala/cats/TraverseFilter.scala +++ b/core/src/main/scala/cats/TraverseFilter.scala @@ -22,7 +22,6 @@ package cats import cats.data.State -import simulacrum.{noop, typeclass} import scala.collection.immutable.{HashSet, TreeSet} @@ -34,7 +33,6 @@ import scala.collection.immutable.{HashSet, TreeSet} * Based on Haskell's [[https://hackage.haskell.org/package/witherable-0.1.3.3/docs/Data-Witherable.html Data.Witherable]] */ -@typeclass trait TraverseFilter[F[_]] extends FunctorFilter[F] { def traverse: Traverse[F] @@ -66,7 +64,7 @@ trait TraverseFilter[F[_]] extends FunctorFilter[F] { * b: Either[String, List[Int]] = Right(List(1, 5, 3)) * }}} */ - @noop + def sequenceFilter[G[_], A](fgoa: F[G[Option[A]]])(implicit G: Applicative[G]): G[F[A]] = traverseFilter(fgoa)(identity) @@ -137,10 +135,6 @@ trait TraverseFilter[F[_]] extends FunctorFilter[F] { object TraverseFilter { - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - /** * Summon an instance of [[TraverseFilter]] for `F`. */ @@ -186,8 +180,4 @@ object TraverseFilter { @deprecated("Use cats.syntax object imports", "2.2.0") object nonInheritedOps extends ToTraverseFilterOps - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - } diff --git a/core/src/main/scala/cats/UnorderedFoldable.scala b/core/src/main/scala/cats/UnorderedFoldable.scala index 1c6ed11168..f694b18570 100644 --- a/core/src/main/scala/cats/UnorderedFoldable.scala +++ b/core/src/main/scala/cats/UnorderedFoldable.scala @@ -24,12 +24,11 @@ package cats import cats.kernel.CommutativeMonoid import scala.collection.immutable.{Queue, Seq, SortedMap, SortedSet} import scala.util.Try -import simulacrum.{noop, typeclass} /** * `UnorderedFoldable` is like a `Foldable` for unordered containers. */ -@typeclass trait UnorderedFoldable[F[_]] extends Serializable { +trait UnorderedFoldable[F[_]] extends Serializable { def unorderedFoldMap[A, B: CommutativeMonoid](fa: F[A])(f: A => B): B @@ -94,7 +93,7 @@ import simulacrum.{noop, typeclass} * res1: Long = 2 * }}} */ - @noop + def count[A](fa: F[A])(p: A => Boolean): Long = unorderedFoldMap(fa)(a => if (p(a)) 1L else 0L) } @@ -144,10 +143,6 @@ object UnorderedFoldable def catsInstancesForTuple[A]: Traverse[(A, *)] with Reducible[(A, *)] = cats.instances.tuple.catsStdInstancesForTuple2[A] - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - /** * Summon an instance of [[UnorderedFoldable]] for `F`. */ @@ -191,8 +186,4 @@ object UnorderedFoldable @deprecated("Use cats.syntax object imports", "2.2.0") object nonInheritedOps extends ToUnorderedFoldableOps - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - } diff --git a/core/src/main/scala/cats/UnorderedTraverse.scala b/core/src/main/scala/cats/UnorderedTraverse.scala index a1a9e81e11..8bd7baffda 100644 --- a/core/src/main/scala/cats/UnorderedTraverse.scala +++ b/core/src/main/scala/cats/UnorderedTraverse.scala @@ -21,12 +21,10 @@ package cats -import simulacrum.typeclass - /** * `UnorderedTraverse` is like a `Traverse` for unordered containers. */ -@typeclass trait UnorderedTraverse[F[_]] extends UnorderedFoldable[F] { +trait UnorderedTraverse[F[_]] extends UnorderedFoldable[F] { def unorderedTraverse[G[_]: CommutativeApplicative, A, B](sa: F[A])(f: A => G[B]): G[F[B]] def unorderedSequence[G[_]: CommutativeApplicative, A](fga: F[G[A]]): G[F[A]] = @@ -35,10 +33,6 @@ import simulacrum.typeclass object UnorderedTraverse { - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - /** * Summon an instance of [[UnorderedTraverse]] for `F`. */ @@ -80,8 +74,4 @@ object UnorderedTraverse { @deprecated("Use cats.syntax object imports", "2.2.0") object nonInheritedOps extends ToUnorderedTraverseOps - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - } diff --git a/core/src/main/scala/cats/arrow/Arrow.scala b/core/src/main/scala/cats/arrow/Arrow.scala index 641c2f5523..812b42b2b3 100644 --- a/core/src/main/scala/cats/arrow/Arrow.scala +++ b/core/src/main/scala/cats/arrow/Arrow.scala @@ -22,12 +22,10 @@ package cats package arrow -import simulacrum.typeclass - /** * Must obey the laws defined in cats.laws.ArrowLaws. */ -@typeclass trait Arrow[F[_, _]] extends Category[F] with Strong[F] { self => +trait Arrow[F[_, _]] extends Category[F] with Strong[F] { self => /** * Lift a function into the context of an Arrow. @@ -66,7 +64,7 @@ import simulacrum.typeclass * Note that the arrow laws do not guarantee the non-interference between the _effects_ of * `f` and `g` in the context of F. This means that `f *** g` may not be equivalent to `g *** f`. */ - @simulacrum.op("***", alias = true) + def split[A, B, C, D](f: F[A, B], g: F[C, D]): F[(A, C), (B, D)] = andThen(first(f), second(g)) @@ -86,17 +84,13 @@ import simulacrum.typeclass * Note that the arrow laws do not guarantee the non-interference between the _effects_ of * `f` and `g` in the context of F. This means that `f &&& g` may not be equivalent to `g &&& f`. */ - @simulacrum.op("&&&", alias = true) + def merge[A, B, C](f: F[A, B], g: F[A, C]): F[A, (B, C)] = andThen(lift((x: A) => (x, x)), split(f, g)) } object Arrow { - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - /** * Summon an instance of [[Arrow]] for `F`. */ @@ -138,8 +132,4 @@ object Arrow { @deprecated("Use cats.syntax object imports", "2.2.0") object nonInheritedOps extends ToArrowOps - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - } diff --git a/core/src/main/scala/cats/arrow/ArrowChoice.scala b/core/src/main/scala/cats/arrow/ArrowChoice.scala index f54331215e..9664edab27 100644 --- a/core/src/main/scala/cats/arrow/ArrowChoice.scala +++ b/core/src/main/scala/cats/arrow/ArrowChoice.scala @@ -22,12 +22,10 @@ package cats package arrow -import simulacrum.typeclass - /** * Must obey the laws defined in cats.laws.ArrowChoiceLaws. */ -@typeclass trait ArrowChoice[F[_, _]] extends Arrow[F] with Choice[F] { self => +trait ArrowChoice[F[_, _]] extends Arrow[F] with Choice[F] { self => /** * ArrowChoice yields Arrows with choice, allowing distribution @@ -50,7 +48,7 @@ import simulacrum.typeclass * res1: Either[Long,Double] = Right(3.0) * }}} */ - @simulacrum.op("+++", alias = true) + def choose[A, B, C, D](f: F[A, C])(g: F[B, D]): F[Either[A, B], Either[C, D]] def left[A, B, C](fab: F[A, B]): F[Either[A, C], Either[B, C]] = @@ -65,10 +63,6 @@ import simulacrum.typeclass object ArrowChoice { - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - /** * Summon an instance of [[ArrowChoice]] for `F`. */ @@ -110,8 +104,4 @@ object ArrowChoice { @deprecated("Use cats.syntax object imports", "2.2.0") object nonInheritedOps extends ToArrowChoiceOps - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - } diff --git a/core/src/main/scala/cats/arrow/Category.scala b/core/src/main/scala/cats/arrow/Category.scala index d58b75a7e0..587ffb23cd 100644 --- a/core/src/main/scala/cats/arrow/Category.scala +++ b/core/src/main/scala/cats/arrow/Category.scala @@ -22,12 +22,10 @@ package cats package arrow -import simulacrum.typeclass - /** * Must obey the laws defined in cats.laws.CategoryLaws. */ -@typeclass trait Category[F[_, _]] extends Compose[F] { self => +trait Category[F[_, _]] extends Compose[F] { self => def id[A]: F[A, A] @@ -46,10 +44,6 @@ import simulacrum.typeclass object Category { - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - /** * Summon an instance of [[Category]] for `F`. */ @@ -87,8 +81,4 @@ object Category { @deprecated("Use cats.syntax object imports", "2.2.0") object nonInheritedOps extends ToCategoryOps - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - } diff --git a/core/src/main/scala/cats/arrow/Choice.scala b/core/src/main/scala/cats/arrow/Choice.scala index 4c2ecb7010..a2ccebcd85 100644 --- a/core/src/main/scala/cats/arrow/Choice.scala +++ b/core/src/main/scala/cats/arrow/Choice.scala @@ -22,9 +22,7 @@ package cats package arrow -import simulacrum.typeclass - -@typeclass trait Choice[F[_, _]] extends Category[F] { +trait Choice[F[_, _]] extends Category[F] { /** * Given two `F`s (`f` and `g`) with a common target type, create a new `F` @@ -45,7 +43,7 @@ import simulacrum.typeclass * res0: String = false is a boolean * }}} */ - @simulacrum.op("|||", alias = true) + def choice[A, B, C](f: F[A, C], g: F[B, C]): F[Either[A, B], C] /** @@ -69,10 +67,6 @@ import simulacrum.typeclass object Choice { - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - /** * Summon an instance of [[Choice]] for `F`. */ @@ -112,8 +106,4 @@ object Choice { @deprecated("Use cats.syntax object imports", "2.2.0") object nonInheritedOps extends ToChoiceOps - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - } diff --git a/core/src/main/scala/cats/arrow/CommutativeArrow.scala b/core/src/main/scala/cats/arrow/CommutativeArrow.scala index 7ad8108cc4..0d72afa443 100644 --- a/core/src/main/scala/cats/arrow/CommutativeArrow.scala +++ b/core/src/main/scala/cats/arrow/CommutativeArrow.scala @@ -22,22 +22,16 @@ package cats package arrow -import simulacrum.typeclass - /** * In a Commutative Arrow F[_, _], the split operation (or `***`) is commutative, * which means that there is non-interference between the effect of the paired arrows. * * Must obey the laws in CommutativeArrowLaws */ -@typeclass trait CommutativeArrow[F[_, _]] extends Arrow[F] +trait CommutativeArrow[F[_, _]] extends Arrow[F] object CommutativeArrow { - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - /** * Summon an instance of [[CommutativeArrow]] for `F`. */ @@ -77,8 +71,4 @@ object CommutativeArrow { @deprecated("Use cats.syntax object imports", "2.2.0") object nonInheritedOps extends ToCommutativeArrowOps - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - } diff --git a/core/src/main/scala/cats/arrow/Compose.scala b/core/src/main/scala/cats/arrow/Compose.scala index 396c129df0..6b60b827d8 100644 --- a/core/src/main/scala/cats/arrow/Compose.scala +++ b/core/src/main/scala/cats/arrow/Compose.scala @@ -22,8 +22,6 @@ package cats package arrow -import simulacrum.typeclass - /** * Must obey the laws defined in cats.laws.ComposeLaws. * @@ -39,12 +37,10 @@ import simulacrum.typeclass * res1: Int = 301 * }}} */ -@typeclass trait Compose[F[_, _]] extends Serializable { self => +trait Compose[F[_, _]] extends Serializable { self => - @simulacrum.op("<<<", alias = true) def compose[A, B, C](f: F[B, C], g: F[A, B]): F[A, C] - @simulacrum.op(">>>", alias = true) def andThen[A, B, C](f: F[A, B], g: F[B, C]): F[A, C] = compose(g, f) @@ -67,10 +63,6 @@ object Compose { implicit def catsInstancesForPartialFunction: ArrowChoice[PartialFunction] with CommutativeArrow[PartialFunction] = cats.instances.partialFunction.catsStdInstancesForPartialFunction - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - /** * Summon an instance of [[Compose]] for `F`. */ @@ -110,8 +102,4 @@ object Compose { @deprecated("Use cats.syntax object imports", "2.2.0") object nonInheritedOps extends ToComposeOps - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - } diff --git a/core/src/main/scala/cats/arrow/Profunctor.scala b/core/src/main/scala/cats/arrow/Profunctor.scala index 45025f44e6..a9a99d587f 100644 --- a/core/src/main/scala/cats/arrow/Profunctor.scala +++ b/core/src/main/scala/cats/arrow/Profunctor.scala @@ -22,15 +22,13 @@ package cats package arrow -import simulacrum.typeclass - /** * A [[Profunctor]] is a [[Contravariant]] functor on its first type parameter * and a [[Functor]] on its second type parameter. * * Must obey the laws defined in cats.laws.ProfunctorLaws. */ -@typeclass trait Profunctor[F[_, _]] extends Serializable { self => +trait Profunctor[F[_, _]] extends Serializable { self => /** * Contramap on the first type parameter and map on the second type parameter @@ -99,10 +97,6 @@ object Profunctor { implicit def catsStrongForPartialFunction: Strong[PartialFunction] = cats.instances.partialFunction.catsStdInstancesForPartialFunction - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - /** * Summon an instance of [[Profunctor]] for `F`. */ @@ -143,8 +137,4 @@ object Profunctor { @deprecated("Use cats.syntax object imports", "2.2.0") object nonInheritedOps extends ToProfunctorOps - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - } diff --git a/core/src/main/scala/cats/arrow/Strong.scala b/core/src/main/scala/cats/arrow/Strong.scala index adcf2bc018..2565742a5a 100644 --- a/core/src/main/scala/cats/arrow/Strong.scala +++ b/core/src/main/scala/cats/arrow/Strong.scala @@ -22,12 +22,10 @@ package cats package arrow -import simulacrum.typeclass - /** * Must obey the laws defined in cats.laws.StrongLaws. */ -@typeclass trait Strong[F[_, _]] extends Profunctor[F] { +trait Strong[F[_, _]] extends Profunctor[F] { /** * Create a new `F` that takes two inputs, but only modifies the first input @@ -62,10 +60,6 @@ import simulacrum.typeclass object Strong { - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - /** * Summon an instance of [[Strong]] for `F`. */ @@ -105,8 +99,4 @@ object Strong { @deprecated("Use cats.syntax object imports", "2.2.0") object nonInheritedOps extends ToStrongOps - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - } diff --git a/core/src/main/scala/cats/syntax/alternative.scala b/core/src/main/scala/cats/syntax/alternative.scala index 2282e7a079..c9f7a1a4c8 100644 --- a/core/src/main/scala/cats/syntax/alternative.scala +++ b/core/src/main/scala/cats/syntax/alternative.scala @@ -23,7 +23,7 @@ package cats package syntax trait AlternativeSyntax { - // TODO: use simulacrum instances eventually + implicit final def catsSyntaxUnite[F[_], G[_], A](fga: F[G[A]]): UniteOps[F, G, A] = new UniteOps[F, G, A](fga) @@ -45,7 +45,7 @@ sealed private[syntax] trait UniteOpsBinCompat0[F[_], G[_], A] extends Any { sel /** * See [[[Alternative.unite[G[_],A](fga:F[G[A]])(implicitFM:cats\.FlatMap[F]*]]] - * + * * Example: * {{{ * scala> import cats.implicits._ @@ -68,7 +68,7 @@ final class SeparateOps[F[_], G[_, _], A, B](protected val fgab: F[G[A, B]]) /** * See [[Alternative.separateFoldable]] - * + * * Example: * {{{ * scala> import cats.implicits._ @@ -85,7 +85,7 @@ sealed private[syntax] trait SeparateOpsBinCompat0[F[_], G[_, _], A, B] extends /** * See [[[Alternative.separate[G[_,_],A,B](fgab:F[G[A,B]])(implicitFM:cats\.FlatMap[F]* Alternative.separate]]] - * + * * Example: * {{{ * scala> import cats.implicits._ @@ -102,7 +102,7 @@ final class GuardOps(private val condition: Boolean) extends AnyVal { /** * See [[Alternative.guard]] - * + * * Example: * {{{ * scala> import cats.implicits._ diff --git a/core/src/main/scala/cats/syntax/group.scala b/core/src/main/scala/cats/syntax/group.scala index 6b9f75b33e..bc07c921d7 100644 --- a/core/src/main/scala/cats/syntax/group.scala +++ b/core/src/main/scala/cats/syntax/group.scala @@ -23,7 +23,6 @@ package cats package syntax trait GroupSyntax extends SemigroupSyntax { - // TODO: use simulacrum instances eventually implicit final def catsSyntaxGroup[A: Group](a: A): GroupOps[A] = new GroupOps[A](a) } diff --git a/core/src/main/scala/cats/syntax/monoid.scala b/core/src/main/scala/cats/syntax/monoid.scala index 6080cbc088..513c0e0ef3 100644 --- a/core/src/main/scala/cats/syntax/monoid.scala +++ b/core/src/main/scala/cats/syntax/monoid.scala @@ -23,7 +23,7 @@ package cats package syntax trait MonoidSyntax extends SemigroupSyntax { - // TODO: use simulacrum instances eventually + implicit final def catsSyntaxMonoid[A: Monoid](a: A): MonoidOps[A] = new MonoidOps[A](a) } diff --git a/core/src/main/scala/cats/syntax/semigroup.scala b/core/src/main/scala/cats/syntax/semigroup.scala index fdc8fc1038..ac4cec95d7 100644 --- a/core/src/main/scala/cats/syntax/semigroup.scala +++ b/core/src/main/scala/cats/syntax/semigroup.scala @@ -23,7 +23,7 @@ package cats package syntax trait SemigroupSyntax { - // TODO: use simulacrum instances eventually + implicit final def catsSyntaxSemigroup[A: Semigroup](a: A): SemigroupOps[A] = new SemigroupOps[A](a) } diff --git a/docs/colophon.md b/docs/colophon.md index 5cd6bd3de6..070b7874e2 100644 --- a/docs/colophon.md +++ b/docs/colophon.md @@ -9,7 +9,6 @@ We would like to thank the maintainers of these supporting projects, and we'd encourage you to check out these projects and consider integrating them into your own projects. - * [simulacrum](https://github.com/typelevel/simulacrum) for minimizing type class boilerplate * [scalacheck](http://scalacheck.org) for property-based testing * [discipline](https://github.com/typelevel/discipline) for encoding and testing laws * [kind-projector](https://github.com/typelevel/kind-projector) for type lambda syntax diff --git a/docs/faq.md b/docs/faq.md index 52f6cc53af..33e73ccb19 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -124,12 +124,6 @@ However, we acknowledge that this type may not meet everyone's needs. The cats-e It may be worth keeping in mind that `IO` and `Task` are pretty blunt instruments (they are essentially the `Any` of side effect management), and you may want to narrow the scope of your effects throughout most of your application. The [free monad](datatypes/freemonad.md) documentation describes a way to abstractly define controlled effects and interpret them into a type such as `IO` or `Task` as late as possible. As more of your code becomes pure through these controlled effects the less it matters which type you end up choosing to represent your side effects. -## What does `@typeclass` mean? - -Cats defines and implements numerous type classes. Unfortunately, encoding these type classes in Scala can incur a large amount of boilerplate. To address this, [Simulacrum](https://github.com/typelevel/simulacrum) introduces `@typeclass`, a macro annotation which generates a lot of this boilerplate. This elevates type classes to a first class construct and increases the legibility and maintainability of the code. Use of simulacrum also ensures consistency in how the type classes are encoded across a project. Cats uses simulacrum wherever possible to encode type classes, and you can read more about it at the [project page](https://github.com/typelevel/simulacrum). - -Note that the one area where simulacrum is intentionally not used is in the `cats-kernel` module. The `cats-kernel` module is intended to be a shared dependency for a number of projects, and as such, it is important that it is both lightweight and very stable from a binary compatibility perspective. At some point there may be a transition from simulacrum to [typeclassic](https://github.com/typelevel/typeclassic), and the binary compatibility of moving between simulacrum and typeclassic is unclear at this point. Avoiding the dependency on simulacrum in `cats-kernel`, provides insulation against any potential binary compatibility problems in such a transition. - ## What do types like `?` and `λ` mean? Cats defines a wealth of type classes and type class instances. For a number of the type class and instance combinations, there is a mismatch between the type parameter requirements of the type class and the type parameter requirements of the data type for which the instance is being defined. For example, the [Either](datatypes/either.md) data type is a type constructor with two type parameters. We would like to be able to define a [Monad](typeclasses/monad.md) for `Either`, but the `Monad` type class operates on type constructors having only one type parameter. diff --git a/docs/guidelines.md b/docs/guidelines.md index bf52a831aa..bfeef18205 100644 --- a/docs/guidelines.md +++ b/docs/guidelines.md @@ -86,10 +86,10 @@ the instances need to be separated out into different abstract class/traits so t with higher priority inherits from the ones with lower priority. The most specific (whose type class is the lowest in the hierarchy) instance should be placed in the abstract class/ trait with the highest priority. Here is an example. ```scala -@typeclass + trait Functor[F[_]] -@typeclass + trait Monad[F[_]] extends Functor ... diff --git a/docs/typeclasses.md b/docs/typeclasses.md index e703e03067..6e7cf551a1 100644 --- a/docs/typeclasses.md +++ b/docs/typeclasses.md @@ -112,7 +112,7 @@ We can do this through Scala's implicit mechanism. ```scala mdoc:reset-object import cats.Monoid -object Demo { +object Demo { final case class Pair[A, B](first: A, second: B) object Pair { @@ -187,8 +187,6 @@ def combineAll[A : Monoid](list: List[A]): A = list.foldRight(Monoid[A].empty)(Monoid[A].combine) ``` -Cats uses [simulacrum][simulacrum] for defining type classes which will auto-generate such an `apply` method. - # Laws Conceptually, all type classes come with laws. These laws constrain implementations for a given @@ -262,4 +260,3 @@ Originally from [@alexknvl](https://gist.github.com/alexknvl/d63508ddb6a728015ac [fbounds]: http://tpolecat.github.io/2015/04/29/f-bounds.html "Returning the "Current" Type in Scala" -[simulacrum]: https://github.com/typelevel/simulacrum "First class syntax support for type classes in Scala" diff --git a/project/plugins.sbt b/project/plugins.sbt index 7b51317467..848436b0fc 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,7 +1,6 @@ val sbtTypelevelVersion = "0.4.9" addSbtPlugin("org.typelevel" % "sbt-typelevel" % sbtTypelevelVersion) addSbtPlugin("org.typelevel" % "sbt-typelevel-site" % sbtTypelevelVersion) -addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.10.0") addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.3") addSbtPlugin("com.github.tkawachi" % "sbt-doctest" % "0.10.0") addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.2.0")