From a13b72d789c6e2ee3d94bd1b19aad3dda0aea3c3 Mon Sep 17 00:00:00 2001 From: nodist Date: Tue, 9 Jun 2026 10:32:38 -0400 Subject: inline fn defs --- docs/type_system/empty.md | 2 +- docs/type_system/fn.md | 110 ---------------------------------------- docs/type_system/function.md | 118 +++++++++++++++++++++++++++++++++++++++++++ docs/type_system/index.md | 2 +- docs/type_system/overload.md | 2 +- 5 files changed, 121 insertions(+), 113 deletions(-) delete mode 100644 docs/type_system/fn.md create mode 100644 docs/type_system/function.md (limited to 'docs/type_system') diff --git a/docs/type_system/empty.md b/docs/type_system/empty.md index 55bdcf1..6097711 100644 --- a/docs/type_system/empty.md +++ b/docs/type_system/empty.md @@ -7,7 +7,7 @@ Container type can be null ## Use with `Option` Union ```text -make_array : Fn[yes] $ ( +make_array : ([yes] ? yes { `some Array $ (1; 2; 3) `nome diff --git a/docs/type_system/fn.md b/docs/type_system/fn.md deleted file mode 100644 index 1bf88c5..0000000 --- a/docs/type_system/fn.md +++ /dev/null @@ -1,110 +0,0 @@ -# Fn - ---- - -```text -Fn_class `alias Enum[ - .unknown; .incomplete; .native - .task; process; .generator; .iterator; .closure; - .bound; - .regex -] - -Fn[Fn_class; RETURN_TYPE; Collection[ARGS]; STATE; List] - -Fn[Fn_class; RETURN_TYPE; ARGS...] -Fn[RETURN_TYPE; ARGS...] -Fn[Fn_class; ARGS...] -Fn[ARGS...] -``` - -# Function Classes - -## Unknown - -Placeholder before evaluation - -## Incomplete - -A function with an incomplete type, type checking occurs at invocation - -## Native - -Native function wrapper - -## Task - -A queue-able function in a process or iterator - -## Process - -A list of tasks with state - -## Generator - -A function for creating an iterator - -## Iterator - -A task creator with state, cannot take arguments, can be called until done - -## Closure - -A task creator with state that can take arguments - -## Bound - -A function with some arguments already set - -## Regex - -Regular Expression - -# Returning - -## \`return - -## Transient Union Return Chaining - -# Iterating - -## \`yield - -Yielding wraps the value in the transient union `Next` - -Return `Void` to stop iteration - -```text -fn : Fn[n] $ ( @ 1 < n {[x] `yield 2 * x; n +: 1 } ) -it : fn `sync 10 -// invoking -@ it {[v] `log v } // 2 4 6 8 10 12 14 16 18 20 -// same as above -@ { - # `sync it { - .value {[v] `log v } - .done { `break } - } -} -``` - -# Calling - -## \`async - -Asynchronous call - -```text -task : `async fn -value : `await task -``` - -## \`sync - -Synchronous call - -If the callee is a process, an inline await with async is used - -```text -fn `sync args // can be turned into `await fn `async args -``` diff --git a/docs/type_system/function.md b/docs/type_system/function.md new file mode 100644 index 0000000..ebd14ea --- /dev/null +++ b/docs/type_system/function.md @@ -0,0 +1,118 @@ +# Function + +--- + +```text +Function_class `alias Enum[ + .unknown; .incomplete; .native + .task; process; .generator; .iterator; .closure; + .bound; + .regex +] + +Function[Function_class; RETURN_TYPE; Collection[TYPE.SYMBOL]; STATE; List] +``` + +# Alias + +```text +Fn[Generic.T; Collection[TYPE.SYMBOL]] `alias Function[Any; Generic.T; Collection[TYPE.SYMBOL]; STATE; List] +``` + +# Inline Definition + +```text +([x; y] x + y) // Fn[Any; Any.x; Any.y] +([I64.x; y] x + y) // Fn[Any; I64.x; Any.y] +``` + +# Function Classes + +## Unknown + +Placeholder before evaluation + +## Incomplete + +A function with an incomplete type, type checking occurs at invocation + +## Native + +Native function wrapper + +## Task + +A queue-able function in a process or iterator + +## Process + +A list of tasks with state + +## Generator + +A function for creating an iterator + +## Iterator + +A task creator with state, cannot take arguments, can be called until done + +## Closure + +A task creator with state that can take arguments + +## Bound + +A function with some arguments already set + +## Regex + +Regular Expression + +# Returning + +## \`return + +## Transient Union Return Chaining + +# Iterating + +## \`yield + +Yielding wraps the value in the transient union `Next` + +Return `Void` to stop iteration + +```text +fn : ([n] @ 1 < n {[x] `yield 2 * x; n +: 1 } ) +it : fn `sync 10 +// invoking +@ it {[v] `log v } // 2 4 6 8 10 12 14 16 18 20 +// same as above +@ { + # `sync it { + .value {[v] `log v } + .done { `break } + } +} +``` + +# Calling + +## \`async + +Asynchronous call + +```text +task : `async fn +value : `await task +``` + +## \`sync + +Synchronous call + +If the callee is a process, an inline await with async is used + +```text +fn `sync args // can be turned into `await fn `async args +``` diff --git a/docs/type_system/index.md b/docs/type_system/index.md index ece02b1..2d39963 100644 --- a/docs/type_system/index.md +++ b/docs/type_system/index.md @@ -72,7 +72,7 @@ Denotes that a field that does not resolve to anything * #### [Var](./var.md) -* #### [Fn](./fn.md) +* #### [Function](./function.md) * #### [Task](./task.md) diff --git a/docs/type_system/overload.md b/docs/type_system/overload.md index 11bf21d..9fd839e 100644 --- a/docs/type_system/overload.md +++ b/docs/type_system/overload.md @@ -11,7 +11,7 @@ Overload[Collection[FNS]] ## Example ```text -add : Overload[Fn[.native; I64; Tuple[I64.x; I64.y]; ...]; Fn[.native; F64; Tuple[F64.x; F64.y]; ...]; ...] +add : Overload[Fn[I64; I64.x; I64.y]; Fn[F64; F64.x; F64.y]; ...] `log add `sync (1; 2) // Valid calls first `log add `sync (1.1; 2.2) // Valid calls second -- cgit v1.2.3