POLYTONE — the AI-native programming language

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.

enums.pt
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")))

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").