Enums

Enums are algebraic data types. Variants can carry associated data. Pattern matching on enums is exhaustiveness-checked.

Simple enums

scratch.xs

Associated data

Variants can hold one or more values. Construct them like function calls.

scratch.xs

Pattern matching on enums

The semantic analyser verifies that all variants are covered. A missing variant is a compile-time error (unless a wildcard is present).

scratch.xs
scratch.xs

Result and Option

XS has built-in Ok, Err, Some, and None constructors for common result/option patterns. They are regular values you can match on.

scratch.xs