Giter Club home page Giter Club logo

Comments (4)

VKFisher avatar VKFisher commented on August 17, 2024 1

@lloydmeta fair enough. Closing this issue since no changes are warranted. Thanks for your responses!

from enumeratum.

lloydmeta avatar lloydmeta commented on August 17, 2024
  1. Depending on where you get the definition of an enum, you might get different answers, but ultimately, they are either defined as "a closed/finite set of values" or set of constant values, etc. With compiled static langs, the additional implication that this set is defined at compile time.

    An instance of a case class created at compile time would not be part of the enum set. Enumeratum (deliberately) ignores any inherited class that is not an object

  2. Circe encoding-to-JSON for a type with an encoder is non-fallible, hence the ability to encode non-members of an enum type

I would need a lot of convincing to budge from (1) (ie. SomeValue case class will remain not an enum member for the foreseeable future), and I don't really know how we can simply solve for (2), either, since it's a Circe thing (and I would likewise need heavy convincing to code something in the encoder that checks for members throws)

from enumeratum.

VKFisher avatar VKFisher commented on August 17, 2024

Huh, I see. I was mistaken about enumeratum's scope then.

In any case, I think that codecs that fail a roundtrip at runtime on some subset of possible values is an issue that needs some sort of resolution. What do you think about these?

  • Updating the documentation with an explicit statement that enumeratum enums are just simple sets of constant values and not full-fledged ADTs (some languages like Rust or Swift name their ADTs Enums so this is a possible source of confusion)
  • Emitting a warning or an error at compile time if there's a non-object value type that enumeratum or circe won't be able to handle

from enumeratum.

lloydmeta avatar lloydmeta commented on August 17, 2024

Updating the documentation with an explicit statement that enumeratum enums are just simple sets of constant values and not full-fledged ADTs (some languages like Rust or Swift name their ADTs Enums so this is a possible source of confusion)

While I can appreciate both Rust and the potential confusion, I think it's sufficiently clear that enums != ADTs when it comes to the Scala context and enumeratum: we have a values: ImmutableSeq[EnumType] as a requirement/main feature, and ADTs are implemented via sealed. That Rust and Swift decided to use enum as a keyword for ADTs/tagged unions (all enums are tagged unions but not all tagged unions are enums) is "interesting", but I don't feel that should require all other enumeration implementations to explicitly call out that they are , in fact, implementing enumerable enumerations.

Emitting a warning or an error at compile time if there's a non-object value type that enumeratum or circe won't be able to handle

This would break a lot of usages of intermediate classes or case classes that are used to construct valid object members.

IMO it would be more sensible to update the findValue macros to emit a warning that there were no members found (though this should probably be a minor version bump).

from enumeratum.

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.