zio-config icon indicating copy to clipboard operation
zio-config copied to clipboard

scala3 auto derivation module (than Magnolia and shapeless).

Open afsalthaj opened this issue 3 years ago • 6 comments

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
}


afsalthaj avatar Apr 05 '21 22:04 afsalthaj

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

danielbe1 avatar Jun 22 '21 15:06 danielbe1

@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 avatar Jun 26 '21 09:06 afsalthaj

@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 avatar Jun 26 '21 09:06 afsalthaj

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 avatar Jun 27 '21 04:06 afsalthaj

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 avatar Jun 27 '21 22:06 afsalthaj

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

afsalthaj avatar Jul 05 '21 07:07 afsalthaj