diff options
| -rw-r--r-- | docs/type_system/error.md | 2 | ||||
| -rw-r--r-- | docs/type_system/fn.md | 50 | ||||
| -rw-r--r-- | docs/type_system/overload.md | 14 | ||||
| -rw-r--r-- | docs/type_system/task.md | 2 | ||||
| -rw-r--r-- | docs/type_system/union.md | 24 |
5 files changed, 79 insertions, 13 deletions
diff --git a/docs/type_system/error.md b/docs/type_system/error.md index dfe95b8..cdcf7d6 100644 --- a/docs/type_system/error.md +++ b/docs/type_system/error.md @@ -7,5 +7,5 @@ An error for reporting, the data used to create it cannot be accessed ```text Error -e : Error $ "This is a string error" +e : Error $ "This is an error" ``` diff --git a/docs/type_system/fn.md b/docs/type_system/fn.md index 6ba8c1d..edbc04a 100644 --- a/docs/type_system/fn.md +++ b/docs/type_system/fn.md @@ -8,18 +8,56 @@ Fn_class `alias Enum[.partial; .complete; .iterator; .closure; .bound; .regex; . Fn[Fn_class; RETURN_TYPE; ARGS; STATE; List] ``` -# Returning +## Transient Union Return -## \`return +### \`return_value -## \`yield +### \`return_error + +### \`return_some + +### \`return_none + +## Transient Union Return Chaining + +# Iterating + +## \`has_next + +## Transient Union Yield + +### \`yield_value + +### \`yield_error + +### \`yield_some + +### \`yield_none + +```text +fn : Fn[x] $ ( @ 1 .. x { `yield_some 2 * x } ) +it : fn `sync 10 +// invoking +@ it { `log v }[v] // Opton[Int[...]].v $ (.some : 2); Opton[Int[...]].v $ (.some : 4) +// same as above +@ `has_next it { `log it() } +``` # Calling -## \`async +## \`call_async -## \`sync +```text +task : `call_async fn +value : `task_wait task +``` + +## \`call_sync ```text -fn `sync args // `await fn `async args +fn `call_sync args // `task_wait fn `call_async args ``` + +## \`call_native + +For calling native code diff --git a/docs/type_system/overload.md b/docs/type_system/overload.md index 142c20a..8fec210 100644 --- a/docs/type_system/overload.md +++ b/docs/type_system/overload.md @@ -3,3 +3,17 @@ --- List of complete functions, selected by signature + +```text +Overload[FN; ...] +``` + +## Example + +```text +add : Overload[Fn[.native; I64; Tuple[I64.x; I64.y]; ...]; Fn[.native; F64; Tuple[F64.x; F64.y]; ...]; ...] + +`log add `call_native (1; 2) // Valid calls first +`log add `call_native (1.1; 2.2) // Valid calls second +`log add `call_native (1; 2.2) // Invalid no signature match +``` diff --git a/docs/type_system/task.md b/docs/type_system/task.md index 475d81a..5f8654d 100644 --- a/docs/type_system/task.md +++ b/docs/type_system/task.md @@ -10,4 +10,4 @@ Task_status `alias Enum[...] Task[Task_status; TYPE] ``` -## \`await +## \`task_wait 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 ``` |
