Skip to content
Advertisement

Tag: algebraic-data-types

Java tagged union / sum types

Is there any way to define a sum type in Java? Java seems to naturally support product types directly, and I thought enums might allow it to support sum types, and inheritance looks like maybe it could do it, but there is at least one case I can’t resolve. To elaborate, a sum type is a type which can have

Advertisement