Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support of sum types for Scala wanted #133

Open
plokhotnyuk opened this issue Apr 10, 2019 · 1 comment
Open

Support of sum types for Scala wanted #133

plokhotnyuk opened this issue Apr 10, 2019 · 1 comment

Comments

@plokhotnyuk
Copy link
Contributor

They have an abstract class or a trait as a base (usually sealed) and several sub-classes or implementations (usually case classes or objects):

sealed trait ADTBase extends Product with Serializable

case class X(a: Int) extends ADTBase

case class Y(b: String, c: Double) extends ADTBase

case object Z extends ADTBase

Most common representation for them is using of additional field with a discriminator value that usually contains a simple name of sub-class or implementation:

{"type":"Y","b":"VVV","c":777}
@zapov
Copy link
Member

zapov commented Apr 17, 2019

In Java this is only supported through the annotation processor.
I'd rather improve the Scala side of things for code-gen than add more options to reflection based implementation ;(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants