Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Sep 13 05:24
  • Sep 13 05:20
    scala-steward opened #126
  • Sep 11 21:25
  • Sep 11 21:21
    scala-steward opened #125
  • Sep 11 07:32
    Travis gnieh/diffson (master) passed (295)
  • Sep 11 07:28

    satabin on master

    Update sbt-codacy-coverage to 1… Merge pull request #120 from sc… (compare)

  • Sep 11 07:28
    satabin closed #120
  • Sep 11 07:15
    Travis gnieh/diffson (master) passed (294)
  • Sep 11 07:11
    Travis gnieh/diffson (master) passed (293)
  • Sep 11 07:08

    satabin on master

    Update sbt to 1.3.0 Merge pull request #121 from sc… (compare)

  • Sep 11 07:08
    satabin closed #121
  • Sep 11 07:06
    satabin closed #119
  • Sep 11 07:06
    satabin closed #122
  • Sep 11 07:05

    satabin on master

    Update circe-core, circe-generi… Merge pull request #124 from sc… (compare)

  • Sep 11 07:05
    satabin closed #124
  • Sep 11 01:18
  • Sep 11 01:13
    scala-steward opened #124
  • Sep 10 08:21
    Travis gnieh/diffson (master) passed (291)
  • Sep 10 08:15

    satabin on master

    Update cats-core to 2.0.0 Merge pull request #123 from sc… (compare)

  • Sep 10 08:15
    satabin closed #123
Ioan Gabriel Georgiu
@manufacturist
Cheers @satabin. Will look over it in the weekend
Lucas Satabin
@satabin
nice, thanks
Lucas Satabin
@satabin
@manufacturist HI, I had to do something with Scala.JS yesterday and ended up settings up diffson to support it, sorry. I didn't change any code for that, just moved around some stuffs and scratched my head to make coverage and travis play well along.
Lucas Satabin
@satabin
I just pushed release 4.0.0-M2 (changelog here: https://github.com/gnieh/diffson/releases/tag/4.0.0-M2)
Ioan Gabriel Georgiu
@manufacturist
@satabin <3 looks good. Good job m8
Lucas Satabin
@satabin
Just published version 4.0.0-M3 with a more robust Play Json deserialization of Json Patches (ticket #92)
Giuseppe Cannella
@gekomad
hi all, any help to use play 2.7 with this code?
  //libraryDependencies += "org.gnieh" %% "diffson-play-json" % "4.0.0-M3"
    import diffson._
    import diffson.lcs._
    import diffson.playJson._
    import diffson.jsonpatch._    
    import diffson.jsonpatch.lcsdiff._
    import org.openqa.selenium.json.Json
    import play.api.libs.json._
    import cats._
    import cats.implicits._

    implicit val lcs =  new Patience[Json]

    val json1 = play.api.libs.json.Json.parse("""{
                        |  "a": 1,
                        |  "b": true,
                        |  "c": ["test", "plop"]
                        |}""".stripMargin)

    val json2 = play.api.libs.json.Json.parse("""{
                        |  "a": 6,
                        |  "c": ["test2", "plop"],
                        |  "d": false
                        |}""".stripMargin)

    val patch = diff(json1, json2)
Lucas Satabin
@satabin
what is the problem?
Giuseppe Cannella
@gekomad
there is an error at implicit line:
Error:(205, 24) could not find implicit value for evidence parameter of type cats.Eq[org.openqa.selenium.json.Json]
Error occurred in an application involving default arguments.
    implicit val lcs = new Patience[Json]

Error:(205, 24) not enough arguments for constructor Patience: (implicit evidence$1: cats.Eq[org.openqa.selenium.json.Json])diffson.lcs.Patience[org.openqa.selenium.json.Json].
Unspecified value parameter evidence$1.
Error occurred in an application involving default arguments.
    implicit val lcs = new Patience[Json]
Lucas Satabin
@satabin
the diffson play-json module is compiled with 2.7.2
which play-json version do you use?
(the exact version)
ok then the problem is that you use Json from selenium in your code
not the one from play-json
why do you import it (the org.openqa.selenium.json.Json import)?
Giuseppe Cannella
@gekomad
I switched to play 2.7.2 and removed org.openqa.selenium.json.Json import and add import play.libs.Json now the error is:
Error:(204, 24) could not find implicit value for evidence parameter of type cats.Eq[play.libs.Json]
Error occurred in an application involving default arguments.
    implicit val lcs = new Patience[Json]

Error:(204, 24) not enough arguments for constructor Patience: (implicit evidence$1: cats.Eq[play.libs.Json])diffson.lcs.Patience[play.libs.Json].
Unspecified value parameter evidence$1.
Error occurred in an application involving default arguments.
    implicit val lcs = new Patience[Json]
Lucas Satabin
@satabin
weird, it should be provided in the playJson object, let me check
The Eq is indeed provided by the thrid import
however, reading the error message, it seems that it is looking for some Json type in play.libs.Json whereas I use the play-api.libs.json.Json one
I am not familiar with the package hierarchy of play, but could it be this is the problem?
Giuseppe Cannella
@gekomad
yes it is. Now compile. New code is:
    //libraryDependencies += "org.gnieh" %% "diffson-play-json" % "4.0.0-M3"
    import diffson._
    import diffson.lcs._
    import diffson.playJson._
    import diffson.jsonpatch._
    import diffson.jsonpatch.lcsdiff._
    import cats._
    import cats.implicits._
    import play.libs.Json

    implicit val lcs = new Patience[play.api.libs.json.JsValue]

    val json1 = play.api.libs.json.Json.parse("""{
                        |  "a": 1,
                        |  "b": true,
                        |  "c": ["test", "plop"]
                        |}""".stripMargin)

    val json2 = play.api.libs.json.Json.parse("""{
                        |  "a": 6,
                        |  "c": ["test2", "plop"],
                        |  "d": false
                        |}""".stripMargin)

    val patch = diff(json1, json2)
thanks a lot
Lucas Satabin
@satabin
wow that's weird
I have to check then
Giuseppe Cannella
@gekomad
you might add the example on github too :)
Lucas Satabin
@satabin
Yes, that's a good idea
but I am puzzled I must admit
because the diffson code uses play.api.libs.json.Json
I have to investigate a bit more
Lucas Satabin
@satabin
Oh I think I know
Json is not the json type for paly json, but JsValue is
import diffson._
import diffson.lcs._
import diffson.playJson._
import diffson.jsonpatch._    
import diffson.jsonpatch.lcsdiff._
import play.api.libs.json._
import cats._
import cats.implicits._

implicit val lcs =  new Patience[JsValue]

val json1 = Json.parse("""{
                    |  "a": 1,
                    |  "b": true,
                    |  "c": ["test", "plop"]
                    |}""".stripMargin)

val json2 = Json.parse("""{
                    |  "a": 6,
                    |  "c": ["test2", "plop"],
                    |  "d": false
                    |}""".stripMargin)

val patch = diff(json1, json2)
this works
Json is an object that allows you to manipulat e JsValues
I am always confused with their naming
Lucas Satabin
@satabin
I just published Diffson 4.0.0-M4 which adds support for scala 2.13.0 and drops support for scala 2.11
Too many dependencies start dropping scala 2.11, so I decided to drop it as well. Plus with scala.js,, it became quite hard to maintain something consistent. if you really need it, let me know, I will sere if I can afford maintaining this legacy version.
For the final 4.0.0 version, I will wait until all dependencies have a final version with scala 2.13
Giuseppe Cannella
@gekomad

using diffson-circe 4.0.0-M4

    import cats.implicits._
    import diffson.circe._

    import diffson.jsonpatch.lcsdiff._

    implicit val lcs = new diffson.lcs.Patience[io.circe.Json]

    val json1 = io.circe.parser.parse("""{
        |  "a": 1,
        |  "b": true,
        |  "c": ["test", "plop"]
        |}""".stripMargin)

    lazy val json2 = io.circe.parser.parse("""{
        |  "a": 6,
        |  "c": ["test2", "plop"],
        |  "d": false
        |}""".stripMargin)

    val patch = for {
      j1 <- json1
      j2 <- json2
    } yield diffson.diff(j1, j2)

    patch match {
      case Left(_) => assert(false)
      case Right(o) =>
        assert(
          o.toString == """JsonPatch(List(Replace(Chain(Left(a)),6,None), Remove(Chain(Left(b)),None), Replace(Chain(Left(c), Right(0)),"test2",None), Add(Chain(Left(d)),false)))"""
        )
    }

    val json3 = for {
      p <- patch
      j <- json1
    } yield p(j)  // (*)

    assert(json3.toString == """Success(Success({"a":6,"c":["test2","plop"],"d":false}))""")

on bottom at line (*) the error is

Error:(43, 14) ambiguous implicit values:
 both method catsStdInstancesForEither in trait EitherInstances of type [A]=> cats.MonadError[[β$0$]scala.util.Either[A,β$0$],A] with cats.Traverse[[β$1$]scala.util.Either[A,β$1$]]
 and method catsStdInstancesForTry in trait TryInstances of type => cats.MonadError[scala.util.Try,Throwable] with cats.CoflatMap[scala.util.Try] with cats.Traverse[scala.util.Try] with cats.Monad[scala.util.Try]
 match expected type cats.MonadError[F,Throwable]
    } yield p(j)

what's wrong?

Lucas Satabin
@satabin
Hi
which scala version are you using?
Lucas Satabin
@satabin
I assume you use scala 2.13, because in 2.12 it is compiling, and I already noticed that scala 2.13 resolves the implicits differently in such a case
I encourage you to explicitly give your F type on the patch apply method
like p[Try](j)
The thing here is that both implicits for Either[Throwable, ?] and Try are valid with same priority for scala 2.13
so the compiler doesn’t know which one to chose
I will check all examples again to make sure they work out of the box with scala 2.13
Giuseppe Cannella
@gekomad
hi @satabin I use 2.13, using p[Try](j) the problem is solved, thanks
Lucas Satabin
@satabin
Glad it helped, I checked all examples in the README they should allwork with scala 2.13