zio / zio-config

Easily use and document any config from anywhere in ZIO apps
https://zio.dev/zio-config
Apache License 2.0
231 stars 112 forks source link

scala3 auto derivation module (than Magnolia and shapeless). #506

Open afsalthaj opened 3 years ago

afsalthaj commented 3 years ago

Probably this would involve a generic module in Scala3, with its own Generic that allows to and fro from tuples.

The intermediate tuple elements can stay as type members, allowing us to use Conversion[Product].to(product) to do a few computations. Incase, we end up needing to propagate the type info of B, use an Aux pattern can be repeated here type Aux[A, X] = Conversion { type B = X }.

This implies the magnolia specific module will look-like-shapeless but through zero dependency (for scala3)

trait Conversion[A] {
  type Out
  def to(a: A): Out
  def from(b: Out): A
}
danielbe1 commented 3 years ago

Id like a shot at tackling this if you don't mind :) I've been dying for zio-config in scala 3!

afsalthaj commented 3 years ago

@danielbe1 Sorry for the late response. Unfortunately, I have already been working on this issue, and I apologise I didn't mention it in the list of assignees.

afsalthaj commented 3 years ago

@danielbe1 Thanks a ton for offering the help. I have been looking for someone up until 1 week before, however, I started straight away once I got some bandwidth.

afsalthaj commented 3 years ago

For those who would like to know the progress, here is it: https://github.com/afsalthaj/zio-config-scala3-auto-derivation

ETA: Mid July, however we will try our best to smash this even before.

afsalthaj commented 3 years ago

There will not be DeriveConfigDescriptor and inheritance pattern of custom derivations. Any custom behaviour related to names and nesting will be part of the annotations: https://github.com/afsalthaj/zio-config-scala3-auto-derivation/blob/master/src/main/scala/zio/config/magnolia/Macros.scala

afsalthaj commented 3 years ago

Draft PR that implements almost all functionalities is here: https://github.com/zio/zio-config/pull/574