Description
follow on from zio/zio-json#752 (comment)
The zio ecosystem doesn't currenly leverage the new scala 3 typeclass derivation machinery. The current pattern of adding implicits to all companion objects and calling Whatever.gen
is maybe a necessary evil for scala 2, but there's no reason that I can see for it in scala 3!
Here's an example with zio-json. https://scastie.scala-lang.org/WjLoashcQxeOvxQ5JfRbTw
This is using an extension method but I think it'd be handy to roll this out across the ecosystem with a version specific trait that anything with a .gen method could extend. It would simply define def derived
and delegate to the existing .gen
method.
As part of this same issue, I think we should look to either depend on or subsume with attribution (ala izumi-reflect) this library into zio so that derivation works for union types https://github.com/iRevive/union-derivation.
Related: Typeclass derivation should now work on typeclasses with variance
scala/scala3#13146