Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Scala 3 derivation instead of Magnolia for Scala 3 #434

Open
fsvehla opened this issue Sep 15, 2021 · 4 comments
Open

Use Scala 3 derivation instead of Magnolia for Scala 3 #434

fsvehla opened this issue Sep 15, 2021 · 4 comments
Assignees

Comments

@fsvehla
Copy link
Contributor

fsvehla commented Sep 15, 2021

Magnolia is moving quite slowly, and I think that I can implement all of it’s functionality
using Scala 3’s auto derivation + a few simple macros for case class annotations.

@plokhotnyuk
Copy link
Contributor

plokhotnyuk commented Sep 15, 2021

It would be great to have some handy approach for derivation configuration without annotations in Scala 3.

As an example, jsoniter-scala-macros for Scala 2 uses a configuration parameter for the make macro, which is passed to the macro implementation as an expression and evaluated in the compile-time using Eval.eval. That allowed to derive codecs with different customization without adding of annotations.

@fsvehla
Copy link
Contributor Author

fsvehla commented Sep 15, 2021

I’ll look into this, @plokhotnyuk, thanks for the pointer :)

@plokhotnyuk
Copy link
Contributor

@fsvehla The problem only that Scala 3 doesn't have Eval.eval anymore...

@fsvehla
Copy link
Contributor Author

fsvehla commented Sep 29, 2021

Work on Decoder looks good, with the snag that I have yet to figure out why all sum type members need to define a Decoder.

  object examplesum {
    sealed abstract class Parent

    object Parent {
      implicit val decoder: JsonDecoder[Parent] = DeriveJsonDecoder.gen
    }

    case class Child1() extends Parent

    object Child1 {
      // not necessary with Magnolia
      implicit val decoder: JsonDecoder[Child1] = DeriveJsonDecoder.gen
    }

    case class Child2() extends Parent

    object Child2 {
      // not necessary with Magnolia
      implicit val decoder: JsonDecoder[Child2] = DeriveJsonDecoder.gen
    }
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants