diff options
Diffstat (limited to 'docs/type_system/union.md')
| -rw-r--r-- | docs/type_system/union.md | 24 |
1 files changed, 19 insertions, 5 deletions
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 ``` |
