Skip to content

Commit

Permalink
Merge pull request #35 from danslapman/chore/simulacrums-comeback
Browse files Browse the repository at this point in the history
Get rid of simulacrum in scala-3 sources
  • Loading branch information
danslapman authored Sep 22, 2024
2 parents 30ba709 + 3ddb0b2 commit d0d157d
Show file tree
Hide file tree
Showing 21 changed files with 88 additions and 939 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## version 4.0.0

> unreleased
- simulacrum-scalafix is removed

## version 3.1.0

> 20.10.2022
Expand Down
90 changes: 45 additions & 45 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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]
}
}
)
Expand All @@ -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"))
Expand All @@ -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 {
Expand All @@ -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"))
Expand All @@ -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, _)) =>
Expand All @@ -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"))
Expand All @@ -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"))
Expand All @@ -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,
Expand All @@ -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("."))
Expand Down
47 changes: 2 additions & 45 deletions circe/src/main/scala-2/morphling/circe/FromJson.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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 */
/* ======================================================================== */

}
47 changes: 2 additions & 45 deletions circe/src/main/scala-2/morphling/circe/ToFilter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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], *]
}

Expand Down Expand Up @@ -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 */
/* ======================================================================== */

}
47 changes: 2 additions & 45 deletions circe/src/main/scala-2/morphling/circe/ToJson.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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 */
/* ======================================================================== */

}
Loading

0 comments on commit d0d157d

Please sign in to comment.