You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm curious if you would consider adding an option to always derive enums as if they were sealed traits/sealed abstract classes? That is, even a simple enum with only singleton cases would still produce a JSON object and could be configured with AdtEncodingStrategy.
Thanks, @mrdziuban, for this proposal.
I was thinking about the distinction between enum instances and singleton objects myself.
Conceptionally they are pretty much the same but technically they are very different, which case objects defining their own type extending Product0 while enum cases simply being instances of their enum type.
If we were to implement the option you are asking for it'd have to be opt-in configurable, since we can't break existing encodings. One way could be to add a enumCasesAsProduct flag to AdtEncodingStrategy.
Would sth like that work for you?
Hi, thank you for this great library!
I'm curious if you would consider adding an option to always derive
enum
s as if they weresealed trait
s/sealed abstract class
es? That is, even a simpleenum
with only singletoncase
s would still produce a JSON object and could be configured withAdtEncodingStrategy
.For example:
I would like
Json.encode(Foo.Bar)
to produce{"Baz":{}}
so I can useenum
s andsealed trait
s interchangeablyThe text was updated successfully, but these errors were encountered: