diff --git a/CHANGELOG.md b/CHANGELOG.md index 96d0ccb..c324931 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## version 4.0.0 + +> unreleased + +- simulacrum-scalafix is removed + ## version 3.1.0 > 20.10.2022 diff --git a/build.sbt b/build.sbt index b158b7d..7e7c1eb 100644 --- a/build.sbt +++ b/build.sbt @@ -8,7 +8,7 @@ val versions = Map( "mouse" -> "1.0.11", "scalacheck" -> "1.15.3", "scalatest" -> "3.2.11", - "simulacrum" -> "0.5.4", + "simulacrum" -> "1.1.0", "paradise" -> "2.1.1", "bm4" -> "0.3.1", "scalatestplus-scalacheck" -> "3.2.11.0", @@ -34,11 +34,8 @@ lazy val morphling = (projectMatrix in file("core")) libraryDependencies ++= { (CrossVersion.partialVersion(scalaVersion.value): @unchecked) match { case Some((2, _)) => - Seq( - "com.chuusai" %% "shapeless" % "2.3.3", - ) - case Some((3, _)) => Seq() - case Some((_, _)) => Seq() + Seq("com.chuusai" %% "shapeless" % "2.3.3") + case Some((3, _)) => Seq.empty[ModuleID] } } ) @@ -52,19 +49,18 @@ lazy val `morphling-scalacheck` = (projectMatrix in file("scalacheck")) ThisBuild / parallelExecution := false, libraryDependencies ++= Seq( "org.typelevel" %% "mouse" % versions("mouse"), - "org.typelevel" %% "simulacrum-scalafix-annotations" % versions("simulacrum"), "org.scalacheck" %% "scalacheck" % versions("scalacheck") ), + libraryDependencies ++= (CrossVersion.partialVersion(scalaVersion.value) match { + case Some((2, _)) => + Seq("io.github.leviysoft" %% "simulacrum" % versions("simulacrum")) + case _ => Seq.empty[ModuleID] + }), libraryDependencies ++= (CrossVersion.partialVersion(scalaVersion.value) match { case Some((2, y)) if y < 13 => Seq(compilerPlugin("org.scalamacros" % "paradise" % versions("paradise") cross CrossVersion.full)) - case _ => - Seq.empty[ModuleID] - }), - addCommandAlias( - "simulacrum", - "scalafixEnable;scalafix AddSerializable;scalafix AddImplicitNotFound;scalafix TypeClassSupport;" - ) + case _ => Seq.empty[ModuleID] + }) ) lazy val `morphling-circe` = (projectMatrix in file("circe")) @@ -77,18 +73,19 @@ lazy val `morphling-circe` = (projectMatrix in file("circe")) libraryDependencies ++= Seq( "io.circe" %% "circe-core" % versions("circe"), "org.typelevel" %% "mouse" % versions("mouse"), - "org.typelevel" %% "simulacrum-scalafix-annotations" % versions("simulacrum"), "org.scalatest" %% "scalatest" % versions("scalatest") % Test, "org.scalacheck" %% "scalacheck" % versions("scalacheck") % Test, "org.scalatestplus" %% "scalacheck-1-15" % versions("scalatestplus-scalacheck") % Test ), - libraryDependencies ++= { + libraryDependencies ++= (CrossVersion.partialVersion(scalaVersion.value) match { + case Some((2, _)) => + Seq("io.github.leviysoft" %% "simulacrum" % versions("simulacrum")) + case _ => Seq.empty[ModuleID] + }), + libraryDependencies += { (CrossVersion.partialVersion(scalaVersion.value): @unchecked) match { - case Some((2, _)) => - Seq( - "com.ironcorelabs" %% "cats-scalatest" % "3.0.0" % Test - ) - case Some((_, _)) => Seq() + case Some((2, _)) => "com.ironcorelabs" %% "cats-scalatest" % "3.1.1" % Test + case Some((3, _)) => "com.ironcorelabs" %% "cats-scalatest" % "4.0.0" % Test } }, libraryDependencies ++= (CrossVersion.partialVersion(scalaVersion.value) match { @@ -97,17 +94,13 @@ lazy val `morphling-circe` = (projectMatrix in file("circe")) compilerPlugin("org.scalamacros" % "paradise" % versions("paradise") cross CrossVersion.full), compilerPlugin("com.olegpy" %% "better-monadic-for" % versions("bm4")) ) - case Some((2, y)) => + case Some((2, _)) => Seq( compilerPlugin("com.olegpy" %% "better-monadic-for" % versions("bm4")) ) case _ => Seq.empty[ModuleID] - }), - addCommandAlias( - "simulacrum", - "scalafixEnable;scalafix AddSerializable;scalafix AddImplicitNotFound;scalafix TypeClassSupport;" - ) + }) ) lazy val `morphling-reactivemongo` = (projectMatrix in file("reactivemongo")) @@ -119,12 +112,16 @@ lazy val `morphling-reactivemongo` = (projectMatrix in file("reactivemongo")) ThisBuild / parallelExecution := false, libraryDependencies ++= Seq( "org.reactivemongo" %% "reactivemongo-bson-api" % "1.0.3", - "org.typelevel" %% "simulacrum-scalafix-annotations" % versions("simulacrum"), "org.typelevel" %% "mouse" % versions("mouse"), "org.scalatest" %% "scalatest" % versions("scalatest") % Test, "org.scalacheck" %% "scalacheck" % versions("scalacheck") % Test, "org.scalatestplus" %% "scalacheck-1-15" % versions("scalatestplus-scalacheck") % Test ), + libraryDependencies ++= (CrossVersion.partialVersion(scalaVersion.value) match { + case Some((2, _)) => + Seq("io.github.leviysoft" %% "simulacrum" % versions("simulacrum")) + case _ => Seq.empty[ModuleID] + }), libraryDependencies ++= { (CrossVersion.partialVersion(scalaVersion.value): @unchecked) match { case Some((2, _)) => @@ -143,17 +140,13 @@ lazy val `morphling-reactivemongo` = (projectMatrix in file("reactivemongo")) compilerPlugin("org.scalamacros" % "paradise" % versions("paradise") cross CrossVersion.full), compilerPlugin("com.olegpy" %% "better-monadic-for" % versions("bm4")) ) - case Some((2, y)) => + case Some((2, _)) => Seq( compilerPlugin("com.olegpy" %% "better-monadic-for" % versions("bm4")) ) case _ => Seq.empty[ModuleID] - }), - addCommandAlias( - "simulacrum", - "scalafixEnable;scalafix AddSerializable;scalafix AddImplicitNotFound;scalafix TypeClassSupport;" - ) + }) ) lazy val `morphling-typed-schema` = (projectMatrix in file("typedschema")) @@ -165,22 +158,23 @@ lazy val `morphling-typed-schema` = (projectMatrix in file("typedschema")) ThisBuild / parallelExecution := false, libraryDependencies ++= Seq( "ru.tinkoff" %% "typed-schema-swagger" % "0.14.3", - "org.typelevel" %% "simulacrum-scalafix-annotations" % versions("simulacrum"), "org.typelevel" %% "mouse" % versions("mouse"), "org.scalatest" %% "scalatest" % versions("scalatest") % Test, "com.stephenn" %% "scalatest-circe" % "0.0.2" % Test, "org.scalaz" %% "scalaz-core" % "7.2.29" % Test ), + libraryDependencies ++= (CrossVersion.partialVersion(scalaVersion.value) match { + case Some((2, _)) => + Seq("io.github.leviysoft" %% "simulacrum" % versions("simulacrum")) + case _ => + Seq.empty[ModuleID] + }), libraryDependencies ++= (CrossVersion.partialVersion(scalaVersion.value) match { case Some((2, y)) if y < 13 => Seq(compilerPlugin("org.scalamacros" % "paradise" % versions("paradise") cross CrossVersion.full)) case _ => Seq.empty[ModuleID] - }), - addCommandAlias( - "simulacrum", - "scalafixEnable;scalafix AddSerializable;scalafix AddImplicitNotFound;scalafix TypeClassSupport;" - ) + }) ) lazy val `morphling-tapir` = (projectMatrix in file("tapir")) @@ -192,7 +186,6 @@ lazy val `morphling-tapir` = (projectMatrix in file("tapir")) ThisBuild / parallelExecution := false, libraryDependencies ++= Seq( "com.softwaremill.sttp.tapir" %% "tapir-core" % "1.0.0", - "org.typelevel" %% "simulacrum-scalafix-annotations" % versions("simulacrum"), "org.typelevel" %% "mouse" % versions("mouse"), "org.scalatest" %% "scalatest" % versions("scalatest") % Test, "org.scalacheck" %% "scalacheck" % versions("scalacheck") % Test, @@ -201,10 +194,17 @@ lazy val `morphling-tapir` = (projectMatrix in file("tapir")) "com.softwaremill.sttp.tapir" %% "tapir-openapi-docs" % "1.0.0" % Test, "com.softwaremill.sttp.apispec" %% "openapi-circe" % "0.2.1" % Test ), - addCommandAlias( - "simulacrum", - "scalafixEnable;scalafix AddSerializable;scalafix AddImplicitNotFound;scalafix TypeClassSupport;" - ) + libraryDependencies ++= (CrossVersion.partialVersion(scalaVersion.value) match { + case Some((2, _)) => + Seq("io.github.leviysoft" %% "simulacrum" % versions("simulacrum")) + case _ => Seq.empty[ModuleID] + }), + libraryDependencies ++= (CrossVersion.partialVersion(scalaVersion.value) match { + case Some((2, y)) if y < 13 => + Seq(compilerPlugin("org.scalamacros" % "paradise" % versions("paradise") cross CrossVersion.full)) + case _ => + Seq.empty[ModuleID] + }) ) lazy val root = (projectMatrix in file(".")) diff --git a/circe/src/main/scala-2/morphling/circe/FromJson.scala b/circe/src/main/scala-2/morphling/circe/FromJson.scala index 2082f69..d65465c 100644 --- a/circe/src/main/scala-2/morphling/circe/FromJson.scala +++ b/circe/src/main/scala-2/morphling/circe/FromJson.scala @@ -9,13 +9,10 @@ import morphling.* import morphling.Schema.* import morphling.annotated.Schema.AnnotatedSchema import mouse.boolean.* -import simulacrum.typeclass +import simulacrum_.typeclass -import scala.annotation.implicitNotFound - -@implicitNotFound("Could not find an instance of FromJson for ${S}") @typeclass -trait FromJson[S[_]] extends Serializable { +trait FromJson[S[_]] { def decoder: S ~> Decoder } @@ -124,44 +121,4 @@ object FromJson { ) } } - - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - - /** - * Summon an instance of [[FromJson]] for `S`. - */ - @inline def apply[S[_]](implicit instance: FromJson[S]): FromJson[S] = instance - - object ops { - implicit def toAllFromJsonOps[S[_], A](target: S[A])(implicit tc: FromJson[S]): AllOps[S, A] { - type TypeClassType = FromJson[S] - } = new AllOps[S, A] { - type TypeClassType = FromJson[S] - val self: S[A] = target - val typeClassInstance: TypeClassType = tc - } - } - trait Ops[S[_], A] extends Serializable { - type TypeClassType <: FromJson[S] - def self: S[A] - val typeClassInstance: TypeClassType - } - trait AllOps[S[_], A] extends Ops[S, A] - trait ToFromJsonOps extends Serializable { - implicit def toFromJsonOps[S[_], A](target: S[A])(implicit tc: FromJson[S]): Ops[S, A] { - type TypeClassType = FromJson[S] - } = new Ops[S, A] { - type TypeClassType = FromJson[S] - val self: S[A] = target - val typeClassInstance: TypeClassType = tc - } - } - object nonInheritedOps extends ToFromJsonOps - - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - } diff --git a/circe/src/main/scala-2/morphling/circe/ToFilter.scala b/circe/src/main/scala-2/morphling/circe/ToFilter.scala index 2447946..4c110f3 100644 --- a/circe/src/main/scala-2/morphling/circe/ToFilter.scala +++ b/circe/src/main/scala-2/morphling/circe/ToFilter.scala @@ -11,16 +11,13 @@ import morphling.* import morphling.Schema.Schema import morphling.annotated.Schema.AnnotatedSchema import mouse.option.* -import simulacrum.typeclass - -import scala.annotation.implicitNotFound +import simulacrum_.typeclass /** * Allows to filter Json via specific schema */ -@implicitNotFound("Could not find an instance of ToFilter for ${S}") @typeclass -trait ToFilter[S[_]] extends Serializable { +trait ToFilter[S[_]] { def filter: S ~> Const[Json => Option[Json], *] } @@ -125,44 +122,4 @@ object ToFilter { override def combine(x: Subset[Json], y: Subset[Json]): Subset[Json] = x &&& y andThen { case (lhs, rhs) => lhs |+| rhs } } - - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - - /** - * Summon an instance of [[ToFilter]] for `S`. - */ - @inline def apply[S[_]](implicit instance: ToFilter[S]): ToFilter[S] = instance - - object ops { - implicit def toAllToFilterOps[S[_], A](target: S[A])(implicit tc: ToFilter[S]): AllOps[S, A] { - type TypeClassType = ToFilter[S] - } = new AllOps[S, A] { - type TypeClassType = ToFilter[S] - val self: S[A] = target - val typeClassInstance: TypeClassType = tc - } - } - trait Ops[S[_], A] extends Serializable { - type TypeClassType <: ToFilter[S] - def self: S[A] - val typeClassInstance: TypeClassType - } - trait AllOps[S[_], A] extends Ops[S, A] - trait ToToFilterOps extends Serializable { - implicit def toToFilterOps[S[_], A](target: S[A])(implicit tc: ToFilter[S]): Ops[S, A] { - type TypeClassType = ToFilter[S] - } = new Ops[S, A] { - type TypeClassType = ToFilter[S] - val self: S[A] = target - val typeClassInstance: TypeClassType = tc - } - } - object nonInheritedOps extends ToToFilterOps - - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - } diff --git a/circe/src/main/scala-2/morphling/circe/ToJson.scala b/circe/src/main/scala-2/morphling/circe/ToJson.scala index e41321a..ceb5693 100644 --- a/circe/src/main/scala-2/morphling/circe/ToJson.scala +++ b/circe/src/main/scala-2/morphling/circe/ToJson.scala @@ -10,13 +10,10 @@ import morphling.* import morphling.Schema.* import morphling.annotated.Schema.AnnotatedSchema import mouse.option.* -import simulacrum.typeclass +import simulacrum_.typeclass -import scala.annotation.implicitNotFound - -@implicitNotFound("Could not find an instance of ToJson for ${S}") @typeclass -trait ToJson[S[_]] extends Serializable { +trait ToJson[S[_]] { def encoder: S ~> Encoder } @@ -109,44 +106,4 @@ object ToJson { p.run.fold(ToJson[P].encoder(_), ToJson[Q].encoder(_)) } } - - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - - /** - * Summon an instance of [[ToJson]] for `S`. - */ - @inline def apply[S[_]](implicit instance: ToJson[S]): ToJson[S] = instance - - object ops { - implicit def toAllToJsonOps[S[_], A](target: S[A])(implicit tc: ToJson[S]): AllOps[S, A] { - type TypeClassType = ToJson[S] - } = new AllOps[S, A] { - type TypeClassType = ToJson[S] - val self: S[A] = target - val typeClassInstance: TypeClassType = tc - } - } - trait Ops[S[_], A] extends Serializable { - type TypeClassType <: ToJson[S] - def self: S[A] - val typeClassInstance: TypeClassType - } - trait AllOps[S[_], A] extends Ops[S, A] - trait ToToJsonOps extends Serializable { - implicit def toToJsonOps[S[_], A](target: S[A])(implicit tc: ToJson[S]): Ops[S, A] { - type TypeClassType = ToJson[S] - } = new Ops[S, A] { - type TypeClassType = ToJson[S] - val self: S[A] = target - val typeClassInstance: TypeClassType = tc - } - } - object nonInheritedOps extends ToToJsonOps - - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - } diff --git a/circe/src/main/scala-3/morphling/circe/FromJson.scala b/circe/src/main/scala-3/morphling/circe/FromJson.scala index 31d0682..7c2e4bf 100644 --- a/circe/src/main/scala-3/morphling/circe/FromJson.scala +++ b/circe/src/main/scala-3/morphling/circe/FromJson.scala @@ -10,12 +10,7 @@ import morphling.Schema.* import morphling.annotated.Schema.AnnotatedSchema import morphling.given import mouse.boolean.* -import simulacrum.typeclass -import scala.annotation.implicitNotFound - -@implicitNotFound("Could not find an instance of FromJson for ${S}") -@typeclass trait FromJson[S[_]] extends Serializable { def decoder: S ~> Decoder @@ -25,6 +20,7 @@ trait FromJson[S[_]] extends Serializable { } object FromJson { + def apply[P[_]](using fj: FromJson[P]): FromJson[P] = fj given [P[_]: FromJson]: FromJson[Schema[P, _]] = new FromJson[Schema[P, _]] { @@ -129,44 +125,4 @@ object FromJson { ) } } - - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - - /** - * Summon an instance of [[FromJson]] for `S`. - */ - @inline def apply[S[_]](implicit instance: FromJson[S]): FromJson[S] = instance - - object ops { - implicit def toAllFromJsonOps[S[_], A](target: S[A])(implicit tc: FromJson[S]): AllOps[S, A] { - type TypeClassType = FromJson[S] - } = new AllOps[S, A] { - type TypeClassType = FromJson[S] - val self: S[A] = target - val typeClassInstance: TypeClassType = tc - } - } - trait Ops[S[_], A] extends Serializable { - type TypeClassType <: FromJson[S] - def self: S[A] - val typeClassInstance: TypeClassType - } - trait AllOps[S[_], A] extends Ops[S, A] - trait ToFromJsonOps extends Serializable { - implicit def toFromJsonOps[S[_], A](target: S[A])(implicit tc: FromJson[S]): Ops[S, A] { - type TypeClassType = FromJson[S] - } = new Ops[S, A] { - type TypeClassType = FromJson[S] - val self: S[A] = target - val typeClassInstance: TypeClassType = tc - } - } - object nonInheritedOps extends ToFromJsonOps - - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - } diff --git a/circe/src/main/scala-3/morphling/circe/ToFilter.scala b/circe/src/main/scala-3/morphling/circe/ToFilter.scala index 5565e18..31e98e1 100644 --- a/circe/src/main/scala-3/morphling/circe/ToFilter.scala +++ b/circe/src/main/scala-3/morphling/circe/ToFilter.scala @@ -12,15 +12,7 @@ import morphling.Schema.Schema import morphling.annotated.Schema.AnnotatedSchema import morphling.given import mouse.option.* -import simulacrum.typeclass -import scala.annotation.implicitNotFound - -/** - * Allows to filter Json via specific schema - */ -@implicitNotFound("Could not find an instance of ToFilter for ${S}") -@typeclass trait ToFilter[S[_]] extends Serializable { def filter: S ~> Const[Json => Option[Json], *] @@ -31,6 +23,8 @@ object ToFilter { type Subset[T] = T => Option[T] type JsonFilter[T] = Const[Subset[Json], T] + def apply[P[_]](using tf: ToFilter[P]): ToFilter[P] = tf + given [P[_]: ToFilter]: ToFilter[Schema[P, _]] = new ToFilter[Schema[P, _]] { override val filter: Schema[P, _] ~> JsonFilter = new (Schema[P, _] ~> JsonFilter) { @@ -127,44 +121,4 @@ object ToFilter { override def combine(x: Subset[Json], y: Subset[Json]): Subset[Json] = x &&& y andThen { case (lhs, rhs) => lhs |+| rhs } } - - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - - /** - * Summon an instance of [[ToFilter]] for `S`. - */ - @inline def apply[S[_]](implicit instance: ToFilter[S]): ToFilter[S] = instance - - object ops { - implicit def toAllToFilterOps[S[_], A](target: S[A])(implicit tc: ToFilter[S]): AllOps[S, A] { - type TypeClassType = ToFilter[S] - } = new AllOps[S, A] { - type TypeClassType = ToFilter[S] - val self: S[A] = target - val typeClassInstance: TypeClassType = tc - } - } - trait Ops[S[_], A] extends Serializable { - type TypeClassType <: ToFilter[S] - def self: S[A] - val typeClassInstance: TypeClassType - } - trait AllOps[S[_], A] extends Ops[S, A] - trait ToToFilterOps extends Serializable { - implicit def toToFilterOps[S[_], A](target: S[A])(implicit tc: ToFilter[S]): Ops[S, A] { - type TypeClassType = ToFilter[S] - } = new Ops[S, A] { - type TypeClassType = ToFilter[S] - val self: S[A] = target - val typeClassInstance: TypeClassType = tc - } - } - object nonInheritedOps extends ToToFilterOps - - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - } diff --git a/circe/src/main/scala-3/morphling/circe/ToJson.scala b/circe/src/main/scala-3/morphling/circe/ToJson.scala index cdf35e2..8957a43 100644 --- a/circe/src/main/scala-3/morphling/circe/ToJson.scala +++ b/circe/src/main/scala-3/morphling/circe/ToJson.scala @@ -10,12 +10,7 @@ import morphling.* import morphling.Schema.* import morphling.annotated.Schema.AnnotatedSchema import mouse.option.* -import simulacrum.typeclass -import scala.annotation.implicitNotFound - -@implicitNotFound("Could not find an instance of ToJson for ${S}") -@typeclass trait ToJson[S[_]] extends Serializable { def encoder: S ~> Encoder @@ -23,6 +18,7 @@ trait ToJson[S[_]] extends Serializable { } object ToJson { + def apply[P[_]](using tj: ToJson[P]): ToJson[P] = tj given [P[_]: ToJson]: ToJson[Schema[P, _]] = new ToJson[Schema[P, _]] { @@ -109,44 +105,4 @@ object ToJson { p.run.fold(ToJson[P].encoder(_), ToJson[Q].encoder(_)) } } - - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - - /** - * Summon an instance of [[ToJson]] for `S`. - */ - @inline def apply[S[_]](implicit instance: ToJson[S]): ToJson[S] = instance - - object ops { - implicit def toAllToJsonOps[S[_], A](target: S[A])(implicit tc: ToJson[S]): AllOps[S, A] { - type TypeClassType = ToJson[S] - } = new AllOps[S, A] { - type TypeClassType = ToJson[S] - val self: S[A] = target - val typeClassInstance: TypeClassType = tc - } - } - trait Ops[S[_], A] extends Serializable { - type TypeClassType <: ToJson[S] - def self: S[A] - val typeClassInstance: TypeClassType - } - trait AllOps[S[_], A] extends Ops[S, A] - trait ToToJsonOps extends Serializable { - implicit def toToJsonOps[S[_], A](target: S[A])(implicit tc: ToJson[S]): Ops[S, A] { - type TypeClassType = ToJson[S] - } = new Ops[S, A] { - type TypeClassType = ToJson[S] - val self: S[A] = target - val typeClassInstance: TypeClassType = tc - } - } - object nonInheritedOps extends ToToJsonOps - - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - } diff --git a/circe/src/test/scala-3/cats/scalatest/EitherValues.scala b/circe/src/test/scala-3/cats/scalatest/EitherValues.scala deleted file mode 100644 index 2bc9fa7..0000000 --- a/circe/src/test/scala-3/cats/scalatest/EitherValues.scala +++ /dev/null @@ -1,90 +0,0 @@ -package cats.scalatest - -import org.scalactic.source -import org.scalatest.exceptions.{StackDepthException, TestFailedException} - -import scala.util.{Either, Left, Right} - -trait EitherValues { - import scala.language.implicitConversions - - /** - * Implicit conversion that adds a `value` method to `scala.util.Either` - * - * @param either - * the `scala.util.Either` on which to add the `value` method - */ - implicit def convertEitherToEitherable[E, T](either: E Either T)(implicit pos: source.Position): Eitherable[E, T] = - new Eitherable(either, pos) - - /** - * Container class for matching success type stuff in `scala.util.Either` containers, similar to - * `org.scalatest.OptionValues.Valuable` - * - * Meant to allow you to make statements like: - * - *
 result.value should be > 15 
- * - * Where it only matches if result is `Valid` and is also greater than 15. - * - * Otherwise your test will fail, indicating that it was left instead of right - * - * @param either - * A `scala.util.Either` object to try converting to a `Eitherable` - * - * @see - * org.scalatest.OptionValues.Valuable - */ - final class Eitherable[E, T](either: E Either T, pos: source.Position) { - - /** - * Extract the `Right` from the Either. If the value is not a right the test will fail. - */ - def value: T = - either match { - case Right(right) => right - case Left(left) => - throw new TestFailedException( - (_: StackDepthException) => Some(s"'$left' is a Left, expected a Right."), - None, - pos - ) - } - - /** - * Use .leftValue on an Either to extract the left side. Like .value, but for the left. If the value is a right, the - * test will fail. - */ - def leftValue: E = - either match { - case Right(right) => - throw new TestFailedException( - (_: StackDepthException) => Some(s"'$right' is a Right, expected a Left."), - None, - pos - ) - case Left(left) => left - } - } -} - -/** - * Companion object for easy importing – rather than mixing in – to allow `EitherValues` operations. - * - * This will permit you to invoke a `value` method on an instance of a `scala.util.Either`, which attempts to unwrap the - * `Valid`. - * - * Similar to `org.scalatest.OptionValues.Valuable` - * - * Meant to allow you to make statements like: - * - *
 result.value should be > 15 
- * - * Where it only matches if result is both an `Either.Vaild` and has a value > 15. - * - * Otherwise your test will fail, indicating that it was an Invalid instead of Valid - * - * @see - * EitherValues.EitherValuable - */ -object EitherValues extends EitherValues diff --git a/circe/src/test/scala-3/cats/scalatest/ValidatedValues.scala b/circe/src/test/scala-3/cats/scalatest/ValidatedValues.scala deleted file mode 100644 index f82fc80..0000000 --- a/circe/src/test/scala-3/cats/scalatest/ValidatedValues.scala +++ /dev/null @@ -1,119 +0,0 @@ -package cats.scalatest - -import cats.data.Validated -import cats.data.Validated.{Invalid, Valid} -import org.scalactic.source -import org.scalatest.exceptions.{StackDepthException, TestFailedException} - -trait ValidatedValues { - import scala.language.implicitConversions - - /** - * Implicit conversion that adds a `value` method to `cats.data.Validated` - * - * @param validated - * the `cats.data.Validated` on which to add the `value` method - */ - implicit def convertValidatedToValidatable[E, T]( - validated: Validated[E, T] - )(implicit pos: source.Position): Validatable[E, T] = - new Validatable(validated, pos) - - /** - * Container class for matching success type stuff in `cats.data.Validated` containers, similar to - * `org.scalatest.OptionValues.Valuable` - * - * Meant to allow you to make statements like: - * - *
 result.value should be > 15 result.valid.value should be(Valid(15)) 
- * - * Where it only matches if result is `Valid(9)` - * - * Otherwise your test will fail, indicating that it was left instead of right - * - * @param validated - * A `cats.data.Validated` object to try converting to a `Validatable` - * - * @see - * org.scalatest.OptionValues.Valuable - */ - final class Validatable[E, T](validated: Validated[E, T], pos: source.Position) { - def value: T = - validated match { - case Valid(valid) => valid - case Invalid(left) => - throw new TestFailedException( - (_: StackDepthException) => Some(s"'$left' is Invalid, expected Valid."), - None, - pos - ) - } - - /** - * Allow .invalidValue on an validated to extract the invalid side. Like .value, but for the `Invalid`. - */ - def invalidValue: E = - validated match { - case Valid(valid) => - throw new TestFailedException( - (_: StackDepthException) => Some(s"'$valid' is Valid, expected Invalid."), - None, - pos - ) - case Invalid(left) => left - } - - /** - * Returns the Validated passed to the constructor as a Valid, if it is a - * Valid, else throws TestFailedException with a detail message indicating the - * Validated was not a Valid. - */ - def valid: Valid[T] = - validated match { - case valid: Valid[T] => valid - case _ => - throw new TestFailedException( - (_: StackDepthException) => Some("The Validated on which valid was invoked was not a Valid."), - None, - pos - ) - } - - /** - * Returns the Validated passed to the constructor as an Invalid, if it is an - * Invalid, else throws TestFailedException with a detail message indicating the - * Validated was not an Invalid. - */ - def invalid: Invalid[E] = - validated match { - case invalid: Invalid[E] => invalid - case _ => - throw new TestFailedException( - (_: StackDepthException) => Some("The Validated on which invalid was invoked was not an Invalid."), - None, - pos - ) - } - } -} - -/** - * Companion object for easy importing – rather than mixing in – to allow `ValidatedValues` operations. - * - * This will permit you to invoke a `value` method on an instance of a `cats.data.Validated`, which attempts to unwrap - * the Validated.Valid - * - * Similar to `org.scalatest.OptionValues.Valuable` - * - * Meant to allow you to make statements like: - * - *
 result.value should be > 15 
- * - * Where it only matches if result is both valid and greater than 15. - * - * Otherwise your test will fail, indicating that it was an Invalid instead of Valid - * - * @see - * org.scalatest.OptionValues.Valuable - */ -object ValidatedValues extends ValidatedValues diff --git a/project/Settings.scala b/project/Settings.scala index 7ebe0d0..ea2b23f 100644 --- a/project/Settings.scala +++ b/project/Settings.scala @@ -2,6 +2,7 @@ import scalafix.sbt.ScalafixPlugin.autoImport._ import sbt.Keys._ import sbt._ +import sbtprojectmatrix.ProjectMatrixKeys._ object Settings { val common = Seq( @@ -12,8 +13,8 @@ object Settings { (CrossVersion.partialVersion(scalaVersion.value): @unchecked) match { case Some((2, 12)) => Seq( + "-Ywarn-unused-import", "-language:higherKinds,implicitConversions", - "-Ywarn-unused:imports", "-deprecation", "-Ypartial-unification", "-Xsource:3", @@ -21,8 +22,8 @@ object Settings { ) case Some((2, 13)) => Seq( + "-Wunused:imports", "-language:higherKinds,implicitConversions", - "-Ywarn-unused:imports", "-deprecation", "-Ymacro-annotations", "-Xsource:3", @@ -31,8 +32,7 @@ object Settings { case Some((3, _)) => Seq( "-Ykind-projector:underscores", - "-source:future", - "-Wunused:imports" + "-source:future" ) } }, @@ -41,7 +41,7 @@ object Settings { scalafixConfig := { (CrossVersion.partialVersion(scalaVersion.value): @unchecked) match { case Some((2, _)) => scalafixConfig.value - case Some((3, _)) => Some(baseDirectory.value.getParentFile.getParentFile.getParentFile / ".scalafix3.conf") + case Some((3, _)) => Some(projectMatrixBaseDirectory.value.getParentFile / ".scalafix3.conf") } }, libraryDependencies ++= { diff --git a/project/plugins.sbt b/project/plugins.sbt index 613b06e..7d91472 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,4 +1,4 @@ addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.12.1") -addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.0") -addSbtPlugin("com.eed3si9n" % "sbt-projectmatrix" % "0.9.0") +addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2") +addSbtPlugin("com.eed3si9n" % "sbt-projectmatrix" % "0.10.0") addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.6.1") \ No newline at end of file diff --git a/reactivemongo/src/main/scala-2/morphling/reactivemongo/FromBson.scala b/reactivemongo/src/main/scala-2/morphling/reactivemongo/FromBson.scala index bee586d..b18cb93 100644 --- a/reactivemongo/src/main/scala-2/morphling/reactivemongo/FromBson.scala +++ b/reactivemongo/src/main/scala-2/morphling/reactivemongo/FromBson.scala @@ -9,13 +9,10 @@ import morphling.{Absent, Alt, Constant, HAlgebra, HEnvT, HFix, IsoSchema, OneOf import mouse.boolean.* import mouse.option.* import reactivemongo.api.bson.* -import simulacrum.typeclass +import simulacrum_.typeclass -import scala.annotation.implicitNotFound - -@implicitNotFound("Could not find an instance of FromBson for ${S}") @typeclass -trait FromBson[S[_]] extends Serializable { +trait FromBson[S[_]] { def reader: S ~> BSONReader } @@ -136,44 +133,4 @@ object FromBson { ) } } - - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - - /** - * Summon an instance of [[FromBson]] for `S`. - */ - @inline def apply[S[_]](implicit instance: FromBson[S]): FromBson[S] = instance - - object ops { - implicit def toAllFromBsonOps[S[_], A](target: S[A])(implicit tc: FromBson[S]): AllOps[S, A] { - type TypeClassType = FromBson[S] - } = new AllOps[S, A] { - type TypeClassType = FromBson[S] - val self: S[A] = target - val typeClassInstance: TypeClassType = tc - } - } - trait Ops[S[_], A] extends Serializable { - type TypeClassType <: FromBson[S] - def self: S[A] - val typeClassInstance: TypeClassType - } - trait AllOps[S[_], A] extends Ops[S, A] - trait ToFromBsonOps extends Serializable { - implicit def toFromBsonOps[S[_], A](target: S[A])(implicit tc: FromBson[S]): Ops[S, A] { - type TypeClassType = FromBson[S] - } = new Ops[S, A] { - type TypeClassType = FromBson[S] - val self: S[A] = target - val typeClassInstance: TypeClassType = tc - } - } - object nonInheritedOps extends ToFromBsonOps - - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - } diff --git a/reactivemongo/src/main/scala-2/morphling/reactivemongo/ToBson.scala b/reactivemongo/src/main/scala-2/morphling/reactivemongo/ToBson.scala index 82fe7d8..07816cf 100644 --- a/reactivemongo/src/main/scala-2/morphling/reactivemongo/ToBson.scala +++ b/reactivemongo/src/main/scala-2/morphling/reactivemongo/ToBson.scala @@ -9,14 +9,12 @@ import morphling.annotated.Schema.AnnotatedSchema import morphling.{Absent, Alt, Constant, HAlgebra, HFix, IsoSchema, OneOfSchema, Optional, PrimSchema, PropSchema, RecordSchema, Required, SchemaF} import mouse.option.* import reactivemongo.api.bson.* -import simulacrum.typeclass +import simulacrum_.typeclass -import scala.annotation.implicitNotFound import scala.util.{Success, Try} -@implicitNotFound("Could not find an instance of ToBson for ${S}") @typeclass -trait ToBson[S[_]] extends Serializable { +trait ToBson[S[_]] { def writer: S ~> BSONWriter } @@ -132,44 +130,4 @@ object ToBson { ) } } - - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - - /** - * Summon an instance of [[ToBson]] for `S`. - */ - @inline def apply[S[_]](implicit instance: ToBson[S]): ToBson[S] = instance - - object ops { - implicit def toAllToBsonOps[S[_], A](target: S[A])(implicit tc: ToBson[S]): AllOps[S, A] { - type TypeClassType = ToBson[S] - } = new AllOps[S, A] { - type TypeClassType = ToBson[S] - val self: S[A] = target - val typeClassInstance: TypeClassType = tc - } - } - trait Ops[S[_], A] extends Serializable { - type TypeClassType <: ToBson[S] - def self: S[A] - val typeClassInstance: TypeClassType - } - trait AllOps[S[_], A] extends Ops[S, A] - trait ToToBsonOps extends Serializable { - implicit def toToBsonOps[S[_], A](target: S[A])(implicit tc: ToBson[S]): Ops[S, A] { - type TypeClassType = ToBson[S] - } = new Ops[S, A] { - type TypeClassType = ToBson[S] - val self: S[A] = target - val typeClassInstance: TypeClassType = tc - } - } - object nonInheritedOps extends ToToBsonOps - - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - } diff --git a/reactivemongo/src/main/scala-3/morphling/reactivemongo/FromBson.scala b/reactivemongo/src/main/scala-3/morphling/reactivemongo/FromBson.scala index b55383e..454cd99 100644 --- a/reactivemongo/src/main/scala-3/morphling/reactivemongo/FromBson.scala +++ b/reactivemongo/src/main/scala-3/morphling/reactivemongo/FromBson.scala @@ -10,12 +10,7 @@ import morphling.{Absent, Alt, Constant, HAlgebra, HEnvT, HFix, IsoSchema, OneOf import mouse.boolean.* import mouse.option.* import reactivemongo.api.bson.* -import simulacrum.typeclass -import scala.annotation.implicitNotFound - -@implicitNotFound("Could not find an instance of FromBson for ${S}") -@typeclass trait FromBson[S[_]] extends Serializable { def reader: S ~> BSONReader @@ -25,6 +20,8 @@ trait FromBson[S[_]] extends Serializable { } object FromBson { + def apply[P[_]](using fb: FromBson[P]): FromBson[P] = fb + given [P[_]: FromBson]: FromBson[Schema[P, _]] = new FromBson[Schema[P, _]] { override val reader: Schema[P, _] ~> BSONReader = new (Schema[P, _] ~> BSONReader) { @@ -139,44 +136,4 @@ object FromBson { ) } } - - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - - /** - * Summon an instance of [[FromBson]] for `S`. - */ - @inline def apply[S[_]](implicit instance: FromBson[S]): FromBson[S] = instance - - object ops { - implicit def toAllFromBsonOps[S[_], A](target: S[A])(implicit tc: FromBson[S]): AllOps[S, A] { - type TypeClassType = FromBson[S] - } = new AllOps[S, A] { - type TypeClassType = FromBson[S] - val self: S[A] = target - val typeClassInstance: TypeClassType = tc - } - } - trait Ops[S[_], A] extends Serializable { - type TypeClassType <: FromBson[S] - def self: S[A] - val typeClassInstance: TypeClassType - } - trait AllOps[S[_], A] extends Ops[S, A] - trait ToFromBsonOps extends Serializable { - implicit def toFromBsonOps[S[_], A](target: S[A])(implicit tc: FromBson[S]): Ops[S, A] { - type TypeClassType = FromBson[S] - } = new Ops[S, A] { - type TypeClassType = FromBson[S] - val self: S[A] = target - val typeClassInstance: TypeClassType = tc - } - } - object nonInheritedOps extends ToFromBsonOps - - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - } diff --git a/reactivemongo/src/main/scala-3/morphling/reactivemongo/ToBson.scala b/reactivemongo/src/main/scala-3/morphling/reactivemongo/ToBson.scala index 4da3828..0efdc28 100644 --- a/reactivemongo/src/main/scala-3/morphling/reactivemongo/ToBson.scala +++ b/reactivemongo/src/main/scala-3/morphling/reactivemongo/ToBson.scala @@ -9,13 +9,9 @@ import morphling.annotated.Schema.AnnotatedSchema import morphling.{Absent, Alt, Constant, HAlgebra, HFix, IsoSchema, OneOfSchema, Optional, PrimSchema, PropSchema, RecordSchema, Required, SchemaF} import mouse.option.* import reactivemongo.api.bson.* -import simulacrum.typeclass -import scala.annotation.implicitNotFound import scala.util.{Success, Try} -@implicitNotFound("Could not find an instance of ToBson for ${S}") -@typeclass trait ToBson[S[_]] extends Serializable { def writer: S ~> BSONWriter @@ -25,6 +21,8 @@ trait ToBson[S[_]] extends Serializable { } object ToBson { + def apply[P[_]](using tb: ToBson[P]): ToBson[P] = tb + given [P[_]: ToBson]: ToBson[Schema[P, _]] = new ToBson[Schema[P, _]] { override val writer: Schema[P, _] ~> BSONWriter = new (Schema[P, _] ~> BSONWriter) { @@ -133,44 +131,4 @@ object ToBson { ) } } - - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - - /** - * Summon an instance of [[ToBson]] for `S`. - */ - @inline def apply[S[_]](implicit instance: ToBson[S]): ToBson[S] = instance - - object ops { - implicit def toAllToBsonOps[S[_], A](target: S[A])(implicit tc: ToBson[S]): AllOps[S, A] { - type TypeClassType = ToBson[S] - } = new AllOps[S, A] { - type TypeClassType = ToBson[S] - val self: S[A] = target - val typeClassInstance: TypeClassType = tc - } - } - trait Ops[S[_], A] extends Serializable { - type TypeClassType <: ToBson[S] - def self: S[A] - val typeClassInstance: TypeClassType - } - trait AllOps[S[_], A] extends Ops[S, A] - trait ToToBsonOps extends Serializable { - implicit def toToBsonOps[S[_], A](target: S[A])(implicit tc: ToBson[S]): Ops[S, A] { - type TypeClassType = ToBson[S] - } = new Ops[S, A] { - type TypeClassType = ToBson[S] - val self: S[A] = target - val typeClassInstance: TypeClassType = tc - } - } - object nonInheritedOps extends ToToBsonOps - - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - } diff --git a/scalacheck/src/main/scala-2/morphling/scalacheck/ToGen.scala b/scalacheck/src/main/scala-2/morphling/scalacheck/ToGen.scala index 134acbf..e99d127 100644 --- a/scalacheck/src/main/scala-2/morphling/scalacheck/ToGen.scala +++ b/scalacheck/src/main/scala-2/morphling/scalacheck/ToGen.scala @@ -8,13 +8,10 @@ import morphling.Schema.Schema import morphling.annotated.Schema.AnnotatedSchema import mouse.option.* import org.scalacheck.Gen -import simulacrum.typeclass +import simulacrum_.typeclass -import scala.annotation.implicitNotFound - -@implicitNotFound("Could not find an instance of ToGen for ${S}") @typeclass -trait ToGen[S[_]] extends Serializable { +trait ToGen[S[_]] { def toGen: S ~> Gen } @@ -90,44 +87,4 @@ object ToGen { ) } } - - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - - /** - * Summon an instance of [[ToGen]] for `S`. - */ - @inline def apply[S[_]](implicit instance: ToGen[S]): ToGen[S] = instance - - object ops { - implicit def toAllToGenOps[S[_], A](target: S[A])(implicit tc: ToGen[S]): AllOps[S, A] { - type TypeClassType = ToGen[S] - } = new AllOps[S, A] { - type TypeClassType = ToGen[S] - val self: S[A] = target - val typeClassInstance: TypeClassType = tc - } - } - trait Ops[S[_], A] extends Serializable { - type TypeClassType <: ToGen[S] - def self: S[A] - val typeClassInstance: TypeClassType - } - trait AllOps[S[_], A] extends Ops[S, A] - trait ToToGenOps extends Serializable { - implicit def toToGenOps[S[_], A](target: S[A])(implicit tc: ToGen[S]): Ops[S, A] { - type TypeClassType = ToGen[S] - } = new Ops[S, A] { - type TypeClassType = ToGen[S] - val self: S[A] = target - val typeClassInstance: TypeClassType = tc - } - } - object nonInheritedOps extends ToToGenOps - - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - } diff --git a/scalacheck/src/main/scala-3/morphling/scalacheck/ToGen.scala b/scalacheck/src/main/scala-3/morphling/scalacheck/ToGen.scala index 4d794b7..7ff82fe 100644 --- a/scalacheck/src/main/scala-3/morphling/scalacheck/ToGen.scala +++ b/scalacheck/src/main/scala-3/morphling/scalacheck/ToGen.scala @@ -9,12 +9,7 @@ import morphling.annotated.Schema.AnnotatedSchema import morphling.given import mouse.option.* import org.scalacheck.Gen -import simulacrum.typeclass -import scala.annotation.implicitNotFound - -@implicitNotFound("Could not find an instance of ToGen for ${S}") -@typeclass trait ToGen[S[_]] extends Serializable { def toGen: S ~> Gen @@ -22,6 +17,8 @@ trait ToGen[S[_]] extends Serializable { } object ToGen { + def apply[S[_]](using toGen: ToGen[S]): ToGen[S] = toGen + given [P[_]: ToGen]: ToGen[Schema[P, _]] = new ToGen[Schema[P, _]] { override val toGen: Schema[P, _] ~> Gen = new (Schema[P, _] ~> Gen) { @@ -91,44 +88,4 @@ object ToGen { ) } } - - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - - /** - * Summon an instance of [[ToGen]] for `S`. - */ - @inline def apply[S[_]](implicit instance: ToGen[S]): ToGen[S] = instance - - object ops { - implicit def toAllToGenOps[S[_], A](target: S[A])(implicit tc: ToGen[S]): AllOps[S, A] { - type TypeClassType = ToGen[S] - } = new AllOps[S, A] { - type TypeClassType = ToGen[S] - val self: S[A] = target - val typeClassInstance: TypeClassType = tc - } - } - trait Ops[S[_], A] extends Serializable { - type TypeClassType <: ToGen[S] - def self: S[A] - val typeClassInstance: TypeClassType - } - trait AllOps[S[_], A] extends Ops[S, A] - trait ToToGenOps extends Serializable { - implicit def toToGenOps[S[_], A](target: S[A])(implicit tc: ToGen[S]): Ops[S, A] { - type TypeClassType = ToGen[S] - } = new Ops[S, A] { - type TypeClassType = ToGen[S] - val self: S[A] = target - val typeClassInstance: TypeClassType = tc - } - } - object nonInheritedOps extends ToToGenOps - - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - } diff --git a/tapir/src/main/scala-2/morphling/tapir/ToSchema.scala b/tapir/src/main/scala-2/morphling/tapir/ToSchema.scala index 7967c70..5a81aae 100644 --- a/tapir/src/main/scala-2/morphling/tapir/ToSchema.scala +++ b/tapir/src/main/scala-2/morphling/tapir/ToSchema.scala @@ -7,15 +7,12 @@ import morphling.* import morphling.Schema.Schema import morphling.annotated.Schema.AnnotatedSchema import mouse.option.* -import simulacrum.typeclass +import simulacrum_.typeclass import sttp.tapir.SchemaType.{SCoproduct, SDiscriminator, SProduct, SProductField} import sttp.tapir.{FieldName, Schema as TapirSchema, SchemaType, Validator} -import scala.annotation.implicitNotFound - -@implicitNotFound("Could not find an instance of ToSchema for ${S}") @typeclass -trait ToSchema[S[_]] extends Serializable { +trait ToSchema[S[_]] { def toSchema: S ~> TapirSchema } @@ -146,49 +143,9 @@ object ToSchema { override val toSchema: EitherK[P, Q, *] ~> TapirSchema = new (EitherK[P, Q, *] ~> TapirSchema) { override def apply[A](fa: EitherK[P, Q, A]): TapirSchema[A] = fa.run.fold( - ToSchema[P].toSchema(_), - ToSchema[Q].toSchema(_), + ToSchema.apply[P].toSchema(_), + ToSchema.apply[Q].toSchema(_), ) } } - - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - - /** - * Summon an instance of [[ToSchema]] for `S`. - */ - @inline def apply[S[_]](implicit instance: ToSchema[S]): ToSchema[S] = instance - - object ops { - implicit def toAllToSchemaOps[S[_], A](target: S[A])(implicit tc: ToSchema[S]): AllOps[S, A] { - type TypeClassType = ToSchema[S] - } = new AllOps[S, A] { - type TypeClassType = ToSchema[S] - val self: S[A] = target - val typeClassInstance: TypeClassType = tc - } - } - trait Ops[S[_], A] extends Serializable { - type TypeClassType <: ToSchema[S] - def self: S[A] - val typeClassInstance: TypeClassType - } - trait AllOps[S[_], A] extends Ops[S, A] - trait ToToSchemaOps extends Serializable { - implicit def toToSchemaOps[S[_], A](target: S[A])(implicit tc: ToSchema[S]): Ops[S, A] { - type TypeClassType = ToSchema[S] - } = new Ops[S, A] { - type TypeClassType = ToSchema[S] - val self: S[A] = target - val typeClassInstance: TypeClassType = tc - } - } - object nonInheritedOps extends ToToSchemaOps - - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - } diff --git a/tapir/src/main/scala-3/morphling/tapir/ToSchema.scala b/tapir/src/main/scala-3/morphling/tapir/ToSchema.scala index 6d22cd8..857f305 100644 --- a/tapir/src/main/scala-3/morphling/tapir/ToSchema.scala +++ b/tapir/src/main/scala-3/morphling/tapir/ToSchema.scala @@ -8,14 +8,9 @@ import morphling.Schema.* import morphling.annotated.Schema.AnnotatedSchema import morphling.given import mouse.option.* -import simulacrum.typeclass import sttp.tapir.SchemaType.{SCoproduct, SDiscriminator, SProduct, SProductField} import sttp.tapir.{FieldName, Schema as TapirSchema, SchemaType, Validator} -import scala.annotation.implicitNotFound - -@implicitNotFound("Could not find an instance of ToSchema for ${S}") -@typeclass trait ToSchema[S[_]] extends Serializable { def toSchema: S ~> TapirSchema @@ -23,6 +18,8 @@ trait ToSchema[S[_]] extends Serializable { } object ToSchema { + def apply[P[_]](using ts: ToSchema[P]): ToSchema[P] = ts + given [P[_]: ToSchema]: ToSchema[Schema[P, _]] = new ToSchema[Schema[P, _]] { override val toSchema: Schema[P, _] ~> TapirSchema = new (Schema[P, _] ~> TapirSchema) { @@ -148,44 +145,4 @@ object ToSchema { p.run.fold(ToSchema[P].toSchema(_), ToSchema[Q].toSchema(_)) } } - - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - - /** - * Summon an instance of [[ToSchema]] for `S`. - */ - @inline def apply[S[_]](implicit instance: ToSchema[S]): ToSchema[S] = instance - - object ops { - implicit def toAllToSchemaOps[S[_], A](target: S[A])(implicit tc: ToSchema[S]): AllOps[S, A] { - type TypeClassType = ToSchema[S] - } = new AllOps[S, A] { - type TypeClassType = ToSchema[S] - val self: S[A] = target - val typeClassInstance: TypeClassType = tc - } - } - trait Ops[S[_], A] extends Serializable { - type TypeClassType <: ToSchema[S] - def self: S[A] - val typeClassInstance: TypeClassType - } - trait AllOps[S[_], A] extends Ops[S, A] - trait ToToSchemaOps extends Serializable { - implicit def toToSchemaOps[S[_], A](target: S[A])(implicit tc: ToSchema[S]): Ops[S, A] { - type TypeClassType = ToSchema[S] - } = new Ops[S, A] { - type TypeClassType = ToSchema[S] - val self: S[A] = target - val typeClassInstance: TypeClassType = tc - } - } - object nonInheritedOps extends ToToSchemaOps - - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - } diff --git a/typedschema/src/main/scala/morphling/tschema/ToTypeable.scala b/typedschema/src/main/scala/morphling/tschema/ToTypeable.scala index c89cd51..2618422 100644 --- a/typedschema/src/main/scala/morphling/tschema/ToTypeable.scala +++ b/typedschema/src/main/scala/morphling/tschema/ToTypeable.scala @@ -10,13 +10,10 @@ import morphling.Schema.Schema import morphling.annotated.Schema.AnnotatedSchema import mouse.option.* import ru.tinkoff.tschema.swagger.{SwaggerObject, SwaggerOneOf, SwaggerPrimitive, SwaggerProperty, SwaggerRef, SwaggerTypeable} -import simulacrum.typeclass +import simulacrum_.typeclass -import scala.annotation.implicitNotFound - -@implicitNotFound("Could not find an instance of ToTypeable for ${S}") @typeclass -trait ToTypeable[S[_]] extends Serializable { +trait ToTypeable[S[_]] { def toTypeable: S ~> SwaggerTypeable } @@ -161,44 +158,4 @@ object ToTypeable { ) } } - - /* ======================================================================== */ - /* THE FOLLOWING CODE IS MANAGED BY SIMULACRUM; PLEASE DO NOT EDIT!!!! */ - /* ======================================================================== */ - - /** - * Summon an instance of [[ToTypeable]] for `S`. - */ - @inline def apply[S[_]](implicit instance: ToTypeable[S]): ToTypeable[S] = instance - - object ops { - implicit def toAllToTypeableOps[S[_], A](target: S[A])(implicit tc: ToTypeable[S]): AllOps[S, A] { - type TypeClassType = ToTypeable[S] - } = new AllOps[S, A] { - type TypeClassType = ToTypeable[S] - val self: S[A] = target - val typeClassInstance: TypeClassType = tc - } - } - trait Ops[S[_], A] extends Serializable { - type TypeClassType <: ToTypeable[S] - def self: S[A] - val typeClassInstance: TypeClassType - } - trait AllOps[S[_], A] extends Ops[S, A] - trait ToToTypeableOps extends Serializable { - implicit def toToTypeableOps[S[_], A](target: S[A])(implicit tc: ToTypeable[S]): Ops[S, A] { - type TypeClassType = ToTypeable[S] - } = new Ops[S, A] { - type TypeClassType = ToTypeable[S] - val self: S[A] = target - val typeClassInstance: TypeClassType = tc - } - } - object nonInheritedOps extends ToToTypeableOps - - /* ======================================================================== */ - /* END OF SIMULACRUM-MANAGED CODE */ - /* ======================================================================== */ - }