Guide
Enums
Sum types with unit and payload variants. Variants are always written qualified — Status.Active — so there is never ambiguity about where a name comes from.
enum Status:
Active
Banned(reason: Text)
fn describe(s: Status) -> Text:
match s:
case Status.Active:
return "active"
case Status.Banned(reason: r):
return "banned: {r}"
fn main() -> Void:
print(describe(Status.Active))
print(describe(Status.Banned(reason: "spam")))$ ptc run enums.pt
Recorded output of the real compiler
Payloads are read by matching only — there is no .field access on an enum value, so every read acknowledges which variant it handles. Equality is structural, and enum values print qualified: Status.Banned(reason: "spam").