Open jdegoes opened 4 years ago
I spent a few hours looking into this. Ignoring tests for now, which are going to have to wait for deps, some import scala.language.implicitConversions
are needed (or stop using implicit conversions) and replacing do / while
with while
according to https://gitter.im/lampepfl/dotty?at=5fbe1088b03a464f082f410d
The efficient replacement for
do { body } while (cond)
iswhile ({ body; cond })
.
Scala 3 in Magnolia is still WIP.
I’m having a branch which uses Scala 3 derivation and implements a subset of the annotations, which I’m now actively working on.
FYI I have a typeclass derivation mechanism that works on Scala 2 and Scala 3. So if we migrated to that we'd get support for both at once.
The only thing I'm concerned about with shapely is that it appears to use nested eithers / tuples.
But I think it could form the basis for adding derivation directly to ZIO Schema. If we have derivation there, then we can implement ZIO JSON derivation in terms of the Schema.
The limitation right now is that ZIO Schema has no concept of annotations. That would have to be thought out and retrofitted into the existing design.
it appears to use nested eithers / tuples
not sure where you see that. The CaseClassN
and SealedTraitN
data types are all "flat" so there's one alloc per transformation (and boxing, if folk are using primitives, but nobody's going to be cracking that problem any time soon...)
@fommil Probably my mistake, I was trying to "read" the generated code from build.sbt. 😄
My proposal would be to incorporate either @fsvehla's ongoing WIP or Shapley (or parts of both) into ZIO Schema, with added support for annotations, and then base ZIO JSON derivation on that.
I’ll make some time to check out ZIO schema this weekend.
magnolia is supposed to support scala 3 now. apparently.
In terms of what's missing, shapely just needs a little macro that can provide access to the annotations, and a little macro that provides the name of a type, and then it should be able to match the magnolia implementation feature for feature.
Isn't this one done?
We should support Scala 3 with the same API as Scala 2. This way users can easily transition from Scala 2 to Scala 3 without having to change any of their ZIO JSON code.
There are several steps to this support: