Created
June 5, 2015 17:28
-
-
Save xuwei-k/9a306226b04f9214f742 to your computer and use it in GitHub Desktop.
play2 Monoid[JsObject] does not satisfy associative law
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
libraryDependencies += "com.typesafe.play" %% "play-json" % "2.4.0" | |
scalaVersion := "2.11.6" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Welcome to Scala version 2.11.6 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_45). | |
Type in expressions to have them evaluated. | |
Type :help for more information. | |
scala> import play.api.libs.json._ | |
import play.api.libs.json._ | |
scala> import play.api.libs.json.Reads.JsObjectMonoid | |
import play.api.libs.json.Reads.JsObjectMonoid | |
scala> val a = Json.obj("key" -> Json.obj("x" -> 1)) | |
a: play.api.libs.json.JsObject = {"key":{"x":1}} | |
scala> val b = Json.obj("key" -> 2) | |
b: play.api.libs.json.JsObject = {"key":2} | |
scala> val c = Json.obj("key" -> Json.obj("y" -> 3)) | |
c: play.api.libs.json.JsObject = {"key":{"y":3}} | |
scala> JsObjectMonoid.append(JsObjectMonoid.append(a, b), c) | |
res0: play.api.libs.json.JsObject = {"key":{"y":3}} | |
scala> JsObjectMonoid.append(a, JsObjectMonoid.append(b, c)) | |
res1: play.api.libs.json.JsObject = {"key":{"x":1,"y":3}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment