∪
Translation status: हिन्दी reader-locale proof. Code fences render through the hi pipeline; prose is canonical Latin.
Inline value unions and discerne on discretio variants.
Syntax: typus <name> = <type> ∪ <type>
Category#
type
Related#
Examples#
radix/corpus/unio/unio.fab (canonical · operator-group)#
Inline value unions and discerne on discretio variants.
# =============================================================================
# ∪ — Inline value unions and discerne on discretio variants.
# =============================================================================
#
# What this teaches:
# • Inline unions — `∪` creates ad-hoc union types without a full `discretio` declaration
# • Tagged variants — `discretio` with `casu` pattern matching for structured payloads
#
# Common mistakes:
# • confusing unio (ad-hoc union typus A ∪ B) with ∪ used as a set operator — unio is a type-level construct
#
# See also: typus, discerne, discretio
# =============================================================================
# Inline value unions and discerne on discretio
#
# typus Valor = numerus ∪ textus models a non-nullable ad-hoc union.
# discretio + discerne handles tagged variants with payloads.
#
# GRAMMAR:
# typeAlias :← 'typus' ident '=' typeExpr ('∪' typeExpr)*
# discerne :← 'discerne' expr '{' 'casu' variant pattern block ... '}'
#
# EXPECTED OUTPUT:
# 42, "salve", "n: 7", "t: faber"
#
# BACKEND: Inline-union `discerne` 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 discretio variants via finge ---
print describe(variant Numerus { v = 7 } ∷ Forma)
print describe(variant Textus { v = "faber" } ∷ Forma)
}Expected output:
42
salve
n: 7
t: faber