OxL Reference

4.4 enum

oxl
pub(api) enum Role { User, Support, Admin }

pub(api) enum Shape {
  Circle(r: f64)
  Rect(w: f64, h: f64)
  Empty
}

@error enum PayError { Declined(reason: str), Fraud, Limit(max: Money) }

@open pub(api) enum Status { New = 1, Paid = 2, Shipped = 3 }
  • A variant: without fields, with positional or with named fields. Construction: Shape.Circle(1.0), Shape.Rect(w: 2, h: 3); when the type is known — .Circle(1.0).
  • Explicit discriminants (= n) are allowed only for an enum without fields.
  • @open — variants may appear in future versions; a match over such an enum outside the package MUST have a _ branch.
  • @error marks a type as an error (§6.5).

See also

Source: docs/spec/oxl-standard.en.md