Skip to content

Union / Sum Datatype #126

@theduke

Description

@theduke

Values can often be one of several datatypes (like string or int, class A or class B, ...).

There should be a way to model unions (anonymous or tagged).

Describing this in the schema is a bit tricky though, since the datatype property is just a single value.

Options:

  • allow the datatype property to be an array of possible types
  • add an additional property for the Property class: somehting like alternativeDataTypes
  • require defining a custom datatype for each union.
    There could be a UnionType class which has a datatypes property, and custom union datatypes specify "isA: "Union". That's rather awkward though, since you could end up with StringOrInt` etc datatypes , which pollute the readability of a schema quite a bit, and more importantly might be duplicated a lot

Non of these is really ideal.

Curios about alternative thoughts here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions