From de1b4d5b6444417a163e90b032f487c91e62c8a4 Mon Sep 17 00:00:00 2001 From: nodist Date: Sat, 16 May 2026 16:12:28 -0400 Subject: specify union classes --- docs/type_system/union.md | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'docs/type_system/union.md') diff --git a/docs/type_system/union.md b/docs/type_system/union.md index f2c4ae0..0f8b65b 100644 --- a/docs/type_system/union.md +++ b/docs/type_system/union.md @@ -3,25 +3,39 @@ --- ```text -Union[TYPE.symbol; ...] +Union_class `alias Enum[.container; .transient] + +Union[Union_class; TYPE.symbol; ...] ``` ```text -u : Union[I64.a; I64.b; I64.c] $ (.c : 5) +u : Union[I64.a; I64.b; I64.c] $ (.c : 5) // defaults to Union[.container; ...] # u { .c { c ... }[c] { ... } // default } ``` + +# Transient Unions + +Can only be retuned from functions and operations. The inner value must be moved out + ## Alias ```text -Result[ANY] `alias Union[ANY.value; Error.error] +Result[ANY] `alias Union[.transient; ANY.value; Error.error] + +Option[ANY] `alias Union[.transient; ANY.some; Void.none] ``` -## \`take +## Default Operation + +When a transient union is assigned the first type specified is moved out. + +If the type is not the first specified a result with an error is returned to the parent function ```text -value : .value `take 10 / var +z : x / y // Result[Int[...]] +z // is value if y is not zero ``` -- cgit v1.2.3