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

Problems with deriving EvoCodec for ADT's #26

Open
kpodsiad opened this issue Sep 6, 2022 · 2 comments
Open

Problems with deriving EvoCodec for ADT's #26

kpodsiad opened this issue Sep 6, 2022 · 2 comments

Comments

@kpodsiad
Copy link
Collaborator

kpodsiad commented Sep 6, 2022

Error messages suggests problem with LazySummon

Base Snippet:

//> using scala "3.2.0"
//> using lib "com.evolution::derivation-circe:0.1-fd8fba2a1f9529f0adc55912129fe9a6974918fc-SNAPSHOT"

import evo.derivation.*
import evo.derivation.circe.*
import evo.derivation.config.Config
import io.circe.Codec

sealed trait MyDataType
final case class Foo(foo: String, bar: Int) extends MyDataType
case object Baz extends MyDataType

Compiling

object MyDataType:
  implicit val config: Config[MyDataType] = Config.derived[MyDataType]
  implicit val actionCodec: Codec[MyDataType] =
    EvoCodec.derived[MyDataType]
object MyDataType:
  given Config[MyDataType] = Config.derived[MyDataType]
  implicit val actionCodec: Codec[MyDataType] =
    EvoCodec.derived[MyDataType]

Not compiling

object MyDataType:
  implicit val actionCodec: Codec[MyDataType] =
    EvoCodec.derived[MyDataType](using Config.derived[MyDataType]) 
object MyDataType:
  val config: Config[MyDataType] = Config.derived[MyDataType]
  implicit val actionCodec: Codec[MyDataType] =
    EvoCodec.derived[MyDataType](using config) 
@Odomontois
Copy link
Collaborator

Yes, currently derivation for constructors requires that there is given Confif for the top enumeration.
We can try to change LazySummon mechanics a little bit if this is a problem

@kpodsiad
Copy link
Collaborator Author

I didn't look through LazySummon code but if config is passed as an implicit parameter via using clause then this shouldn't be enough?

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

No branches or pull requests

2 participants