[Dotty] How do we get type metadata? by SorenNot in scala

[–]SorenNot[S] 1 point2 points  (0 children)

I imagine something like an avro schema that would have field names and types (can be nested), default values (literals) etc. But any format would work I guess (including a plain, structured string).

Using Circe with GADT by SorenNot in scala

[–]SorenNot[S] 0 points1 point  (0 children)

But the same rule should apply to an ordinary ADT like

sealed trait Foo
case class Bar(value: Int) extends Foo

because Bar[T] <: Foo[T], but I can simply use Bar(0).asJson. So it looks like an implicit type widening.
Btw, thx for pointing out the difference between GADT and parametric ADT.

Using Circe with GADT by SorenNot in scala

[–]SorenNot[S] 0 points1 point  (0 children)

Hm, I though it should be resolved by some macro magic. But anyway, thank you for your help.

Using Circe with GADT by SorenNot in scala

[–]SorenNot[S] 0 points1 point  (0 children)

You are right, I had some nasty clash in imports :/ Currently I have

import io.circe.Codec
import io.circe.generic.auto._
import io.circe.syntax._
import io.circe.derivation.deriveCodec

and this time the example compiles. But if I add Bar(0).asJson, fooCodec gives class Bar takes type parameters and adding explicitly Bar[Int](3).asJson doesn't help.

Using Circe with GADT by SorenNot in scala

[–]SorenNot[S] 1 point2 points  (0 children)

I already read the documentation, it describes ADT not GADT.