https://github.com/xuwei-k/json4s-monoid/blob/b81187378f62f/src/test/scala/Spec.scala
上記は正しい例。以下はMonoid則を満たさない例
implicit def JValueInstance: Monoid[JValue] = Monoid.instance(_ merge _, JObject(Nil)) implicit def JValueInstance: Monoid[JValue] = Monoid.instance(_ ++ _, JObject(Nil)) implicit def JValueInstance: Monoid[JValue] = Monoid.instance(_ ++ _, JNull)
参考↓
https://github.com/json4s/json4s/blob/v3.2.4_2.10/tests/src/test/scala/org/json4s/JsonAstSpec.scala#L40-L58
https://github.com/json4s/json4s/blob/v3.2.4_2.10/scalaz/src/main/scala/org/json4s/scalaz/JsonScalaz.scala#L41