-
Notifications
You must be signed in to change notification settings - Fork 143
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
Implement auto deriving without derives
clause for scala 3
#624
Comments
derives
clause derives
clause for scala 3
Most likely releated: scala/scala3#8183 |
This might has been solved. Use by name param in def eqSum[T](s: Mirror.SumOf[T], elems: => List[Eq[_]]): Eq[T] =
new Eq[T]:
def eqv(x: T, y: T): Boolean =
val ordx = s.ordinal(x)
(s.ordinal(y) == ordx) && check(elems(ordx))(x, y)
def eqProduct[T](p: Mirror.ProductOf[T], elems: => List[Eq[_]]): Eq[T] =
new Eq[T]:
def eqv(x: T, y: T): Boolean =
iterator(x).zip(iterator(y)).zip(elems.iterator).forall {
case ((x, y), elem) => check(elem)(x, y)
}
inline given derived[T](using m: Mirror.Of[T]): Eq[T] =
lazy val elemInstances = summonAll[m.MirroredElemTypes]
inline m match
case s: Mirror.SumOf[T] => eqSum(s, elemInstances)
case p: Mirror.ProductOf[T] => eqProduct(p, elemInstances) It seems magnolia does not handle recursive types : |
Hi do you have a work around to deal with recursive types in Scala 3 ? |
I build a codec layer on circe here |
If the request is to bring the Circe |
Like circe:
If we could do this. There will be less boilerplate code.
For example , use tapir to generate openapi, if i use zio-json as json plugin, i have to write at least 10+ gen statement.
I tried to add auto deriving with
but get a compile error infinite inline loops on recursive structure.
The text was updated successfully, but these errors were encountered: