union-derivation icon indicating copy to clipboard operation
union-derivation copied to clipboard

Please consider upstreaming to Scala3

Open bertlebee opened this issue 2 years ago • 1 comments

Hi, thanks for the awesome library! I'm using heaps of unions so this is a lifesaver. Would you consider upstreaming this to Scala3? I think this is a missing feature that really belongs in the standard lib.

bertlebee avatar Oct 28 '22 23:10 bertlebee

Hi.

When Scala 3 was released, I also expected this functionality to be a part of the standard library. And I still think it should be available out of the box.

I see several issues with upstreaming the library. It's relatively simple to derive a Show typeclass, but things are getting complicated with io.circe.Decoder. In some scenarios, the decoding logic should rely on the discriminators (e.g. https://circe.github.io/circe/codecs/adt.html#the-future).

In terms of derivation, a union type is somewhat similar to a sealed trait (ignoring that type Union = String | String is a valid definition). Hence, with a few adjustments, it should be possible to derive a typeclass utilizing Mirror.SumOf (a few hints https://github.com/typelevel/shapeless-3/issues/21#issuecomment-934331200).

Once I formalize my ideas, I will make a proposition in dotty repository.

iRevive avatar Oct 31 '22 10:10 iRevive