Comments (4)
@lloydmeta fair enough. Closing this issue since no changes are warranted. Thanks for your responses!
from enumeratum.
-
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 anobject
-
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.
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 ADTsEnums
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
orcirce
won't be able to handle
from enumeratum.
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)
- Any suggested way to forbid calls to `toString` on `EnumEntry`ies? HOT 2
- Cannot initialize enum value with static final Java field HOT 3
- 1.7.1 release is not found in registry HOT 2
- Enums with hierarchical structure HOT 2
- Avoid the use of `toString` for `enumEntry`? HOT 4
- [Scala 2] Compile-time stackoverflow with lots of enum values HOT 3
- Version 1.7.2 is not binary compatible with previous versions HOT 2
- Conflict with Scala 3 enums HOT 5
- Breaking compatibility should trigger a major version update HOT 2
- .
- enumeratum-json4s not available for Scala3? HOT 7
- Scala3: findValues fails to compile in nested sealed trait hierarchy HOT 1
- Scala 3: findValues fails to find entries extending types with type parameters HOT 1
- How to upgrade enumeratum-doobie to target v1.0.0-RC4 HOT 3
- Un-sealed abstract class in hierarchy gets ignored on Scala 3.x HOT 1
- Support play-json 3.0.x
- Members of enums nested in a class are not discovered in scala 3 HOT 1
- Enumeratum-Play 1.8.0 with Play 3 and Pekko cannot find play.api.libs.json.KeyReads at runtime HOT 2
- Override a single entry with custom name HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from enumeratum.