Skip to content

Commit 05f217b

Browse files
author
j
committed
2.11 compat
1 parent 495a14c commit 05f217b

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

build.sbt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1+
scalaVersion := "2.12.1"
2+
3+
crossScalaVersions := Seq(
4+
"2.11.8"
5+
)
6+
17
lazy val commonSettings = Seq(
28
organization := "org.zalando",
3-
scalaVersion := "2.12.1",
49
scalacOptions ++= Seq("-feature", "-unchecked", "-deprecation")
510
)
611

circe/src/main/scala/org/zalando/jsonapi/json/circe/CirceJsonapiRootObjectWriter.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ import io.circe.Decoder, Decoder.Result
1212
import scala.collection.immutable.ListMap
1313

1414
trait CirceJsonapiRootObjectWriter extends JsonapiRootObjectWriter[Json] {
15+
// proxying Decoder.Result with transparent right biasing for scala 2.11
16+
implicit class CrossVersionResult[R](result: Either[DecodingFailure, R]) {
17+
18+
def map[Y](f: (R) Y): Either[DecodingFailure, Y] = result.right.map(f)
19+
def flatMap[AA >: DecodingFailure, Y](f: (R) Either[AA, Y]): Either[AA, Y] = result.right.flatMap(f)
20+
}
21+
1522
def writeValue(json: Json): Value = {
1623
json.fold[Value](
1724
NullValue,

0 commit comments

Comments
 (0)