evolution-gaming / derivation Goto Github PK
View Code? Open in Web Editor NEWConfigured derivation library for scala 3
License: MIT License
Configured derivation library for scala 3
License: MIT License
Error messages suggests problem with LazySummon
//> 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
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]
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)
By default, mac os filesystem is case insensitive so files like Config.scala
and config.scala
are treated as the same file.
Of course, this issue can be solved on user side - they need to create another partition which will be case sensitive but it can be a bit of ceremony for users which use company provided macbooks.
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])
//> 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
import io.circe.syntax.*
final case class Foo(foo: String) extends AnyVal derives Config, EvoCodec
Infinite loop in function body given_Encoder_Representation
Infinite loop in function body given_Decoder_Representation
circe-generic-extras
has strictDecoding
option which is missing here.
//> using scala "3.2.0"
//> using lib "com.evolution::derivation-circe:0.1.2-SNAPSHOT"
import evo.derivation.*
import evo.derivation.circe.*
import evo.derivation.config.Config
sealed trait Animal derives Config, EvoCodec
sealed trait Mammal
sealed trait Reptile
final case class Dog() extends Mammal
could not derive evo.derivation.circe.EvoEncoder[Animal], look's like Animal is neither case class or enum
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.