Git Product home page Git Product logo

derivation's People

Contributors

evolution-scala-bot[bot] avatar funfunfine avatar kpodsiad avatar mergify[bot] avatar odomontois avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

derivation's Issues

Problems with deriving EvoCodec for ADT's

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) 

Support nested hierarchies

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

Consider rename of `config.scala` file

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.

Cannot derive codec for value classes

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

Screenshot 2022-09-06 at 17 22 56

Provide more user friendly way to derive codecs

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]) 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.