Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

monocle3, scala3 upgrade #336

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.12.17, 2.13.7]
scala: [2.13.7, 3.2.2]
java: [temurin@11, temurin@17]
project: [rootJS, rootJVM]
exclude:
- scala: 2.12.17
- scala: 3.2.2
java: temurin@17
- project: rootJS
java: temurin@17
Expand Down Expand Up @@ -188,42 +188,42 @@ jobs:
~/Library/Caches/Coursier/v1
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}

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

- name: Inflate target directories (2.12.17, rootJS)
- name: Inflate target directories (2.13.7, rootJS)
run: |
tar xf targets.tar
rm targets.tar

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

- name: Inflate target directories (2.12.17, rootJVM)
- name: Inflate target directories (2.13.7, rootJVM)
run: |
tar xf targets.tar
rm targets.tar

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

- name: Inflate target directories (2.13.7, rootJS)
- name: Inflate target directories (3.2.2, rootJS)
run: |
tar xf targets.tar
rm targets.tar

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

- name: Inflate target directories (2.13.7, rootJVM)
- name: Inflate target directories (3.2.2, rootJVM)
run: |
tar xf targets.tar
rm targets.tar
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ limitations under the License.
[circe]: https://github.com/circe/circe
[code-of-conduct]: https://www.scala-lang.org/conduct.html
[contributing]: https://circe.github.io/circe/contributing.html
[monocle]: https://github.com/julien-truffaut/Monocle
[monocle]: https://github.com/optics-dev/Monocle
11 changes: 6 additions & 5 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
val Versions = new {
val circe = "0.14.5"
val monocle = "2.1.0"
val monocle = "3.2.0"
val discipline = "2.1.5"
val scalaTestPlus = "3.2.11.0"

val previousCirceOptics = "0.14.1"

val scala212 = "2.12.17"
val scala213 = "2.13.7"
val scala3 = "3.2.2"

val scalaVersions = Seq(scala212, scala213)
val scalaVersions = Seq(scala213, scala3)
}

ThisBuild / crossScalaVersions := Versions.scalaVersions
Expand All @@ -27,8 +27,9 @@ lazy val optics = crossProject(JVMPlatform, JSPlatform)
description := "Monocle lenses and other tools for working with JSON values",
mimaPreviousArtifacts := Set("io.circe" %% "circe-optics" % Versions.previousCirceOptics),
libraryDependencies ++= Seq(
"com.github.julien-truffaut" %%% "monocle-core" % Versions.monocle,
"com.github.julien-truffaut" %%% "monocle-law" % Versions.monocle % Test,
"dev.optics" %%% "monocle-core" % Versions.monocle,
"dev.optics" %%% "monocle-macro" % Versions.monocle % Test,
"dev.optics" %%% "monocle-law" % Versions.monocle % Test,
"io.circe" %%% "circe-core" % Versions.circe,
"io.circe" %%% "circe-generic" % Versions.circe % Test,
"io.circe" %%% "circe-testing" % Versions.circe % Test,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,6 @@ trait JsonNumberOptics {
)
}

final object JsonNumberOptics extends JsonNumberOptics {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stop scala3 compiler warning, also applies to other occurrences.

object JsonNumberOptics extends JsonNumberOptics {
private[optics] def isNegativeZero(jn: JsonNumber): Boolean = jn.toBiggerDecimal.isNegativeZero
}
8 changes: 4 additions & 4 deletions optics/src/main/scala/io/circe/optics/JsonObjectOptics.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ trait JsonObjectOptics extends ListInstances {

implicit final lazy val jsonObjectEach: Each[JsonObject, Json] = new Each[JsonObject, Json] {
final def each: Traversal[JsonObject, Json] = new Traversal[JsonObject, Json] {
final def modifyF[F[_]](f: Json => F[Json])(from: JsonObject)(implicit
final def modifyA[F[_]](f: Json => F[Json])(from: JsonObject)(implicit
F: Applicative[F]
): F[JsonObject] = from.traverse(f)
}
Expand All @@ -60,8 +60,8 @@ trait JsonObjectOptics extends ListInstances {

implicit final lazy val jsonObjectFilterIndex: FilterIndex[JsonObject, String, Json] =
new FilterIndex[JsonObject, String, Json] {
final def filterIndex(p: String => Boolean) = new Traversal[JsonObject, Json] {
final def modifyF[F[_]](f: Json => F[Json])(from: JsonObject)(implicit
final def filterIndex(p: String => Boolean): Traversal[JsonObject, Json] = new Traversal[JsonObject, Json] {
final def modifyA[F[_]](f: Json => F[Json])(from: JsonObject)(implicit
F: Applicative[F]
): F[JsonObject] =
F.map(
Expand All @@ -75,4 +75,4 @@ trait JsonObjectOptics extends ListInstances {
implicit final lazy val jsonObjectIndex: Index[JsonObject, String, Json] = Index.fromAt
}

final object JsonObjectOptics extends JsonObjectOptics
object JsonObjectOptics extends JsonObjectOptics
22 changes: 11 additions & 11 deletions optics/src/main/scala/io/circe/optics/JsonOptics.scala
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ import monocle.function.Plated
trait JsonOptics {
final lazy val jsonNull: Prism[Json, Unit] = Prism[Json, Unit](j => if (j.isNull) Some(()) else None)(_ => Json.Null)
final lazy val jsonBoolean: Prism[Json, Boolean] = Prism[Json, Boolean](_.asBoolean)(Json.fromBoolean)
final lazy val jsonBigDecimal: Prism[Json, BigDecimal] = jsonNumber.composePrism(jsonNumberBigDecimal)
final lazy val jsonBigInt: Prism[Json, BigInt] = jsonNumber.composePrism(jsonNumberBigInt)
final lazy val jsonLong: Prism[Json, Long] = jsonNumber.composePrism(jsonNumberLong)
final lazy val jsonInt: Prism[Json, Int] = jsonNumber.composePrism(jsonNumberInt)
final lazy val jsonShort: Prism[Json, Short] = jsonNumber.composePrism(jsonNumberShort)
final lazy val jsonByte: Prism[Json, Byte] = jsonNumber.composePrism(jsonNumberByte)
final lazy val jsonBigDecimal: Prism[Json, BigDecimal] = jsonNumber.andThen(jsonNumberBigDecimal)
final lazy val jsonBigInt: Prism[Json, BigInt] = jsonNumber.andThen(jsonNumberBigInt)
final lazy val jsonLong: Prism[Json, Long] = jsonNumber.andThen(jsonNumberLong)
final lazy val jsonInt: Prism[Json, Int] = jsonNumber.andThen(jsonNumberInt)
final lazy val jsonShort: Prism[Json, Short] = jsonNumber.andThen(jsonNumberShort)
final lazy val jsonByte: Prism[Json, Byte] = jsonNumber.andThen(jsonNumberByte)
final lazy val jsonString: Prism[Json, String] = Prism[Json, String](_.asString)(Json.fromString)
final lazy val jsonNumber: Prism[Json, JsonNumber] = Prism[Json, JsonNumber](_.asNumber)(Json.fromJsonNumber)
final lazy val jsonObject: Prism[Json, JsonObject] = Prism[Json, JsonObject](_.asObject)(Json.fromJsonObject)
Expand All @@ -72,20 +72,20 @@ trait JsonOptics {

/** points to all values of a JsonObject or JsonList */
final lazy val jsonDescendants: Traversal[Json, Json] = new Traversal[Json, Json] {
override def modifyF[F[_]](f: Json => F[Json])(s: Json)(implicit F: Applicative[F]): F[Json] =
override def modifyA[F[_]](f: Json => F[Json])(s: Json)(implicit F: Applicative[F]): F[Json] =
s.fold(
F.pure(s),
_ => F.pure(s),
_ => F.pure(s),
_ => F.pure(s),
arr => F.map(Each.each[Vector[Json], Json].modifyF(f)(arr))(Json.arr(_: _*)),
obj => F.map(Each.each[JsonObject, Json].modifyF(f)(obj))(Json.fromJsonObject)
arr => F.map(Each.each[Vector[Json], Json].modifyA(f)(arr))(Json.arr(_: _*)),
obj => F.map(Each.each[JsonObject, Json].modifyA(f)(obj))(Json.fromJsonObject)
)
}

implicit final lazy val jsonPlated: Plated[Json] = new Plated[Json] {
val plate: Traversal[Json, Json] = new Traversal[Json, Json] {
def modifyF[F[_]](f: Json => F[Json])(a: Json)(implicit
def modifyA[F[_]](f: Json => F[Json])(a: Json)(implicit
F: Applicative[F]
): F[Json] =
a.fold(
Expand All @@ -100,4 +100,4 @@ trait JsonOptics {
}
}

final object JsonOptics extends JsonOptics
object JsonOptics extends JsonOptics
Loading