Skip to content

Commit 58f6c03

Browse files
Merge pull request alexarchambault#3 from alexarchambault/topic/circe-0.6
Switch to circe 0.6
2 parents 04d968d + ffe56dc commit 58f6c03

File tree

12 files changed

+124
-130
lines changed

12 files changed

+124
-130
lines changed

build.sbt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
val jupyterScalaVersion = "0.3.0-M3"
3-
val circeVersion = "0.4.1"
3+
val circeVersion = "0.6.1"
44
val plotlyVersion = "1.12.0"
55

66
lazy val core = crossProject
@@ -27,11 +27,11 @@ lazy val `circe-alt-generic` = crossProject
2727
.settings(
2828
name := "circe-alt-generic",
2929
libraryDependencies ++= Seq(
30-
"io.circe" %%% "circe-core" % "0.4.1",
31-
"io.circe" %%% "circe-parser" % "0.4.1",
32-
"com.chuusai" %%% "shapeless" % "2.3.1",
33-
"com.github.alexarchambault" %%% "scalacheck-shapeless_1.13" % "1.1.0-RC3" % "test",
34-
"com.lihaoyi" %%% "utest" % "0.3.0" % "test"
30+
"io.circe" %%% "circe-core" % circeVersion,
31+
"io.circe" %%% "circe-parser" % circeVersion,
32+
"com.chuusai" %%% "shapeless" % "2.3.2",
33+
"com.github.alexarchambault" %%% "scalacheck-shapeless_1.13" % "1.1.4" % "test",
34+
"com.lihaoyi" %%% "utest" % "0.4.4" % "test"
3535
),
3636
testFrameworks += new TestFramework("utest.runner.Framework")
3737
)
@@ -58,7 +58,7 @@ lazy val render = crossProject
5858
.jsSettings(
5959
libraryDependencies ++= Seq(
6060
"io.circe" %%% "circe-scalajs" % circeVersion,
61-
"org.scala-js" %%% "scalajs-dom" % "0.9.0"
61+
"org.scala-js" %%% "scalajs-dom" % "0.9.1"
6262
)
6363
)
6464

@@ -75,7 +75,7 @@ lazy val demo = project
7575
test in Test := (),
7676
testOnly in Test := (),
7777
libraryDependencies ++= Seq(
78-
"com.lihaoyi" %%% "scalatags" % "0.5.5"
78+
"com.lihaoyi" %%% "scalatags" % "0.6.2"
7979
),
8080
jsDependencies ++= Seq(
8181
("org.webjars.bower" % "plotly.js" % plotlyVersion intransitive()) / "plotly.min.js" commonJSName "Plotly",
@@ -173,7 +173,7 @@ lazy val tests = project
173173
name := "plotly-tests",
174174
libraryDependencies ++= Seq(
175175
"io.circe" %% "circe-literal" % circeVersion % "test",
176-
"org.scalatest" %% "scalatest" % "3.0.0-M11" % "test",
176+
"org.scalatest" %% "scalatest" % "3.0.1" % "test",
177177
"org.mozilla" % "rhino" % "1.7.7.1" % "test"
178178
)
179179
)

circe-alt-generic/shared/src/main/scala/io/circe/altgeneric/derive/JsonProductCodec.scala

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package io.circe.altgeneric
22
package derive
33

4-
import cats.data.Xor
54
import io.circe.{ ACursor, Decoder, HCursor, Json }
65

76
abstract class JsonProductCodec {
@@ -46,18 +45,18 @@ class JsonProductObjCodec extends JsonProductCodec {
4645
obj.mapObject((toJsonName(name) -> content) +: _)
4746
}
4847

49-
def decodeEmpty(cursor: HCursor): Decoder.Result[Unit] = Xor.right(())
48+
def decodeEmpty(cursor: HCursor): Decoder.Result[Unit] = Right(())
5049
def decodeField[A](name: String, cursor: HCursor, decode: Decoder[A], default: Option[A]): Decoder.Result[(A, ACursor)] = {
5150
val c = cursor.downField(toJsonName(name))
52-
def result = c.as(decode).map((_, ACursor.ok(cursor)))
51+
def result = c.as(decode).right.map((_, ACursor.ok(cursor)))
5352

5453
default match {
5554
case None => result
5655
case Some(d) =>
5756
if (c.succeeded)
5857
result
5958
else
60-
Xor.right((d, ACursor.ok(cursor)))
59+
Right((d, ACursor.ok(cursor)))
6160
}
6261
}
6362
}

circe-alt-generic/shared/src/main/scala/io/circe/altgeneric/derive/JsonSumCodec.scala

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package io.circe.altgeneric
22
package derive
33

4-
import cats.data.Xor
54
import io.circe._
65

76
abstract class JsonSumCodec {
@@ -45,16 +44,16 @@ class JsonSumObjCodec extends JsonSumCodec {
4544
}
4645

4746
def decodeEmpty(cursor: HCursor): Decoder.Result[Nothing] =
48-
Xor.left(DecodingFailure(
47+
Left(DecodingFailure(
4948
s"unrecognized type(s): ${cursor.fields.getOrElse(Nil).mkString(", ")}",
5049
cursor.history
5150
))
5251
def decodeField[A](name: String, cursor: HCursor, decode: Decoder[A]): Decoder.Result[Either[ACursor, A]] =
5352
cursor.downField(toJsonName(name)).either match {
54-
case Xor.Left(_) =>
55-
Xor.right(Left(ACursor.ok(cursor)))
56-
case Xor.Right(content) =>
57-
decode(content).map(Right(_))
53+
case Left(_) =>
54+
Right(Left(ACursor.ok(cursor)))
55+
case Right(content) =>
56+
decode(content).right.map(Right(_))
5857
}
5958
}
6059

@@ -74,18 +73,21 @@ class JsonSumTypeFieldCodec extends JsonSumCodec {
7473
}
7574

7675
def decodeEmpty(cursor: HCursor): Decoder.Result[Nothing] =
77-
Xor.Left(DecodingFailure(
76+
Left(DecodingFailure(
7877
cursor.downField(typeField).focus match {
7978
case None => "no type found"
8079
case Some(type0) => s"unrecognized type: $type0"
8180
},
8281
cursor.history
8382
))
84-
def decodeField[A](name: String, cursor: HCursor, decode: Decoder[A]): Decoder.Result[Either[ACursor, A]] =
85-
cursor.downField(typeField).as[String] match {
86-
case Xor.Right(name0) if toTypeValue(name) == name0 =>
87-
decode(cursor).map(Right(_))
83+
def decodeField[A](name: String, cursor: HCursor, decode: Decoder[A]): Decoder.Result[Either[ACursor, A]] = {
84+
val c = cursor.downField(typeField)
85+
86+
c.as[String] match {
87+
case Right(name0) if toTypeValue(name) == name0 =>
88+
c.delete.as(decode).right.map(Right(_))
8889
case _ =>
89-
Xor.Right(Left(ACursor.ok(cursor)))
90+
Right(Left(ACursor.ok(cursor)))
9091
}
92+
}
9193
}

circe-alt-generic/shared/src/main/scala/io/circe/altgeneric/derive/MkDecoder.scala

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package io.circe.altgeneric
22
package derive
33

4-
import cats.data.Xor
54
import shapeless._
65
import shapeless.labelled.{FieldType, field}
76
import io.circe.Decoder
@@ -85,6 +84,7 @@ object HListProductDecoder {
8584
Decoder.instance { c =>
8685
productCodec
8786
.decodeEmpty(c)
87+
.right
8888
.map(_ => HNil)
8989
}
9090
}
@@ -100,10 +100,9 @@ object HListProductDecoder {
100100

101101
Decoder.instance { c =>
102102
for {
103-
x <- productCodec.decodeField(key.value.name, c, headDecode.value, defaults.head)
104-
(h, remaining) = x
105-
t <- remaining.as(tailDecode0)
106-
} yield field[K](h) :: t
103+
x <- productCodec.decodeField(key.value.name, c, headDecode.value, defaults.head).right
104+
t <- x._2.as(tailDecode0).right
105+
} yield field[K](x._1) :: t
107106
}
108107
}
109108
}
@@ -127,6 +126,7 @@ object CoproductSumDecoder {
127126
Decoder.instance { c =>
128127
sumCodec
129128
.decodeEmpty(c)
129+
.right
130130
.map(t => t: CNil)
131131
}
132132
}
@@ -141,9 +141,9 @@ object CoproductSumDecoder {
141141
lazy val tailDecode0 = tailDecode(sumCodec)
142142

143143
Decoder.instance { c =>
144-
sumCodec.decodeField(key.value.name, c, headDecode.value).flatMap {
145-
case Left(tailCursor) => tailCursor.as(tailDecode0).map(Inr(_))
146-
case Right(h) => Xor.right(Inl(field[K](h)))
144+
sumCodec.decodeField(key.value.name, c, headDecode.value).right.flatMap {
145+
case Left(tailCursor) => tailCursor.as(tailDecode0).right.map(Inr(_))
146+
case Right(h) => Right(Inl(field[K](h)))
147147
}
148148
}
149149
}

circe-alt-generic/shared/src/test/scala/io/circe/altgeneric/DefaultTests.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package io.circe.altgeneric
22

3-
import cats.data.Xor
43
import io.circe.{ Decoder, Encoder, Json }
54
import utest._
65

@@ -34,11 +33,11 @@ object DefaultTests extends TestSuite {
3433
assert(json1 == expectedJson1)
3534

3635
val result0 = decoder.decodeJson(expectedJson0)
37-
val expectedResult0 = Xor.right(value0)
36+
val expectedResult0 = Right(value0)
3837
assert(result0 == expectedResult0)
3938

4039
val result1 = decoder.decodeJson(expectedJson1)
41-
val expectedResult1 = Xor.right(value1)
40+
val expectedResult1 = Right(value1)
4241
assert(result1 == expectedResult1)
4342
}
4443
}

circe-alt-generic/shared/src/test/scala/io/circe/altgeneric/PriorityTestsDefn.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ object PriorityTestsDefn {
1010
object CC {
1111
implicit val decode: Decoder[CC] = new Decoder[CC] with Flag {
1212
def apply(c: HCursor) =
13-
Decoder[(String, Int)].apply(c).map { case (s, i) =>
13+
Decoder[(String, Int)].apply(c).right.map { case (s, i) =>
1414
CC(s, i)
1515
}
1616
}

circe-alt-generic/shared/src/test/scala/io/circe/altgeneric/ShapelessTests.scala

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import org.scalacheck.{ Arbitrary, Prop }
44
import shapeless.test.illTyped
55
import utest._
66
import Util._
7-
import cats.data.Xor
87
import io.circe.{ Decoder, Encoder, Json, parser => Parse }
98
import io.circe.syntax._
109

@@ -15,7 +14,7 @@ object ShapelessTests extends TestSuite {
1514
private def sameAfterBeforeSerialization[T: Arbitrary : Encoder : Decoder]: Unit =
1615
Prop.forAll {
1716
t: T =>
18-
toFromJson(t) == Xor.right(t)
17+
toFromJson(t) == Right(t)
1918
}.validate
2019

2120
import org.scalacheck.Shapeless._
@@ -55,10 +54,10 @@ object ShapelessTests extends TestSuite {
5554
}
5655

5756
'oiLoose - {
58-
val json = Parse.parse("{}").toOption.get
57+
val json = Parse.parse("{}").right.toOption.get
5958
// assert macro crashes if result is substituted by its value below
6059
val result = json.as[OI]
61-
assert(result == Xor.right(OI(None)))
60+
assert(result == Right(OI(None)))
6261
}
6362

6463
'base - {

project/plugins.sbt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
addSbtPlugin("io.get-coursier" % "sbt-coursier" % "1.0.0-M13")
2-
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.11")
1+
addSbtPlugin("io.get-coursier" % "sbt-coursier" % "1.0.0-M14-9")
2+
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.13")
33
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.0")
44
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.1.9")

0 commit comments

Comments
 (0)