I experimented with upgrading a codebase to 3.4.0 RC4 that previously was compiling OK on RC1.
I hit a new compiler error in a recursive given
definition that compiles fine under RC1. The code in question is a clause in the definition of an cats.kernel.Order[circe.io.Json]
instance (alas an ordering is not defined by Circe out of the box).
given jsonOrder: Order[Json] = Order.from:
case (IsJsonObj(a), IsJsonObj(b)) => jsonObjOrder.compare(a, b)
case (IsJsonString(a), IsJsonString(b)) => Order[String].compare(a, b)
case (IsJsonNumber(a), IsJsonNumber(b)) => jsonNumberOrder.compare(a, b)
case (IsJsonBoolean(a), IsJsonBoolean(b)) => Order[Boolean].compare(a, b)
case (IsJsonArray(a), IsJsonArray(b)) => Order[Vector[Json]].compare(a, b)
case (IsJsonNull(), IsJsonNull()) => 0
case (a, b) => jsonSubtypeTag(a) - jsonSubtypeTag(b)
The error is in Order[Vector[Json]].compare(a, b)
:
[error] |I found:
[error] |
[error] | cats.kernel.Eq.catsKernelOrderForVector[io.circe.Json](
[error] | /* missing */summon[cats.kernel.Order[io.circe.Json]])
[error] |
[error] |But no implicit values were found that match type cats.kernel.Order[io.circe.Json].
To resolve this code will recursively need the instance being defined, when building an instance of Order[Vector[Json]]
.
I noticed RC2 had some changes that look relevant. Presumably, recursive givens are still supported (?), but I may need to set some compiler flags (current "-source", "future"
) or other tweaks to port this code to RC4…?
Is someone familiar with the changes to recursive givens able to advise? Or if this ought to “just work”, I can file an issue with a bigger self-contained example…