∪
Declares a type alias.
Translation status: English reader-locale proof. Term names and code fences follow the en pack; supporting prose may still be English.
Inline value unions and match on union variants.
Syntax: type <name> = <type> ∪ <type>
Category#
type
Related#
Examples#
radix/corpus/unio/unio.fab (canonical · operator-group)#
Inline value unions and match on union variants.
# =============================================================================
# ∪ — Inline value unions and match on union variants.
# =============================================================================
#
# What this teaches:
# • Inline unions — `∪` creates ad-hoc union types without a full `union` declaration
# • Tagged variants — `union` with `case` pattern matching for structured payloads
#
# Common mistakes:
# • confusing unio (ad-hoc union type A ∪ B) with ∪ used as a set operator — unio is a type-level construct
#
# See also: type, match, union
# =============================================================================
# Inline value unions and match on union
#
# type Valor = int ∪ string models a non-nullable ad-hoc union.
# union + match handles tagged variants with payloads.
#
# GRAMMAR:
# typeAlias :← 'type' ident '=' typeExpr ('∪' typeExpr)*
# match :← 'match' expr '{' 'case' variant pattern block ... '}'
#
# EXPECTED OUTPUT:
# 42, "salve", "n: 7", "t: faber"
#
# BACKEND: Inline-union `match` enum lowering gap on Rust (whitelist: unio/unio.fab).
type Valor = int ∪ string
union Forma {
Numerus { int v },
Textus { string v }
}
fn describe(Forma f) → string {
match f {
case Numerus const v { return "n: §"(v) }
case Textus const v { return "t: §"(v) }
}
}
main {
# --- Ad-hoc inline union values ---
const Valor a ← 42
const Valor b ← "salve"
print a
print b
# --- Tagged union variants via variant ---
print describe(variant Numerus { v = 7 } ∷ Forma)
print describe(variant Textus { v = "faber" } ∷ Forma)
}Expected output:
42
salve
n: 7
t: faber