Skip to content
This repository has been archived by the owner on Mar 1, 2024. It is now read-only.

Handle tagged unions with fewer than two cases #115

Closed
tpetrucciani opened this issue Jan 24, 2020 · 0 comments · Fixed by #116
Closed

Handle tagged unions with fewer than two cases #115

tpetrucciani opened this issue Jan 24, 2020 · 0 comments · Fixed by #116
Assignees

Comments

@tpetrucciani
Copy link
Contributor

tpetrucciani commented Jan 24, 2020

Code generation for tagged unions currently works only when they have at least two cases (otherwise, it generates invalid code). However, tagged unions with fewer than two cases are used in our code and can make sense.

Specifically, we sometimes use them to represent error types for uniformity with those with more cases: one case for a single kind of error, zero if the route cannot give errors.

Metarpheus generates the usual model:

{
  "name": "ErrorTraitName",
  "values": [
    {
      "name": "ClassOrObjectExtendingErrorTraitName",
      "params": [ ... ],
      "isValueClass": false
    }
  ],
  "package": [ ... ],
  "_type": "TaggedUnion"
}

The zero-case variant (empty values) could possibly be just a synonym for never.

From buildo/retro#107.

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

Successfully merging a pull request may close this issue.

2 participants