Types & data

One construct: type

Ascent has exactly one way to define a type — the keyword type — and it covers what other languages split into records, enums, and sum types. The only thing that changes is how many variants you write.

One variant with fields is a record:

Several variants with no fields is an enum:

type Size = Small | Medium | Large;

And several variants with fields is a union — the general case the other two are just corners of:

type Shape =
  | Circle{ radius: Float }
  | Rect{ width: Float, height: Float };

Records, enums, sum types: one idea here, told apart only by their variants.