Skip to content

Provide more user friendly way to derive codecs #25

@kpodsiad

Description

@kpodsiad

Annotation based configuration is super useful, but it might be hard to use in cases when one's datatypes are part of e.g. public API and are shared among few apps. Bringing circe, cats and friends into scope is almost impossible.

Of course one can use derived methods explicitly, but it's not as convenient as using circe's deriveConfiguredCodec and similar. Snippet included to issue doesn't use any configuration options but each one of them will require additional codes which is not easy to write as there are almost no comments in sources.

Reproduction uses scala-cli and locally published version of library.

//> 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

final case class MyDataType(foo: String, bar: Int)

object MyDataType:
  implicit val actionCodec: Codec[MyDataType] =
    EvoCodec.derived[MyDataType](using Config.derived[MyDataType]) 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions