GithubHelp home page GithubHelp logo

Add codecs for singleton types about circe HOT 5 CLOSED

circe avatar circe commented on August 24, 2024
Add codecs for singleton types

from circe.

Comments (5)

travisbrown avatar travisbrown commented on August 24, 2024

Are there practical use cases for this? The refined module makes sense to me, but this seems to duplicate the role of other (less clunky) validation mechanisms.

I agree that this doesn't seem to fit nicely in generic, and while it'd only take a very simple macro to add it to core, I'm not sure we want to give up circe's macro-free status for something without a clear payoff.

from circe.

alexarchambault avatar alexarchambault commented on August 24, 2024

I typically use these when the underlying protocol expects a constant value. This allows to put / expect constant values in JSON objects, while still using auto-codecs.

from circe.

fthomas avatar fthomas commented on August 24, 2024

If you're going to add support for refined, you could accomplish the same with

case class CC(
  i: Int,
  message: String @@ Equal[Witness.`"test"`.T]
)

from circe.

alexarchambault avatar alexarchambault commented on August 24, 2024

@fthomas I agree, it's nice to have the simple Witness."test".T too.

I don't see it as a validation mechanism... It's just a way to put constants in the output.

These would just be codecs for singleton types, that are around anyway.

from circe.

travisbrown avatar travisbrown commented on August 24, 2024

This is resolved by #162, which is now in master.

from circe.

Related Issues (20)

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.