aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authors-ol <s-ol@users.noreply.github.com>2020-05-21 16:14:08 +0000
committers-ol <s+removethis@s-ol.nu>2025-03-02 14:24:49 +0000
commit7f52fda5f6c073340f92a05c023f0b45cb6c75f1 (patch)
tree9151495ade690ecde3927311e7e2161179573c24
parentadd builtin get (diff)
downloadalive-7f52fda5f6c073340f92a05c023f0b45cb6c75f1.tar.gz
alive-7f52fda5f6c073340f92a05c023f0b45cb6c75f1.zip
move array and struct constructor into builtins
-rw-r--r--alv-lib/array.moon22
-rw-r--r--alv-lib/struct.moon25
-rw-r--r--alv/builtin.moon44
3 files changed, 42 insertions, 49 deletions
diff --git a/alv-lib/array.moon b/alv-lib/array.moon
deleted file mode 100644
index 752b1ff..0000000
--- a/alv-lib/array.moon
+++ /dev/null
@@ -1,22 +0,0 @@
-import PureOp, Constant, T, Array, val, evt from require 'alv.base'
-
-any = val! / evt!
-
-array = Constant.meta
- meta:
- name: 'array'
- summary: "Construct an array."
- examples: { '(array a b c…)' }
- description: "Produces an array of values."
-
- value: class extends PureOp
- pattern: any!*0
- type: (args) => Array #args, args[1]\type!
-
- tick: =>
- args = @unwrap_all!
- @out\set args
-
-{
- :array
-}
diff --git a/alv-lib/struct.moon b/alv-lib/struct.moon
deleted file mode 100644
index f949536..0000000
--- a/alv-lib/struct.moon
+++ /dev/null
@@ -1,25 +0,0 @@
-import PureOp, Constant, T, Struct, const, val, evt from require 'alv.base'
-
-key = const.str / const.sym
-val = val! / evt!
-pair = (key + val)\named 'key', 'val'
-
-struct = Constant.meta
- meta:
- name: 'struct'
- summary: "Construct an struct."
- examples: { '(struct key1 val1 [key2 val2…])' }
- description: "Produces an struct of values."
-
- value: class extends PureOp
- pattern: pair*0
- type: (pairs) =>
- Struct {key.result!, val\type! for {:key, :val} in *pairs}
-
- tick: =>
- pairs = @unwrap_all!
- @out\set {key, val for {:key, :val} in *pairs}
-
-{
- :struct
-}
diff --git a/alv/builtin.moon b/alv/builtin.moon
index bef4a58..7038de4 100644
--- a/alv/builtin.moon
+++ b/alv/builtin.moon
@@ -5,7 +5,8 @@
-- documentation.
--
-- @module builtin
-import Builtin, Op, T, FnDef, Input, const, val, evt from require 'alv.base'
+import Builtin, Op, PureOp, T, FnDef, Input, const, val, evt, Struct, Array
+ from require 'alv.base'
import Constant from require 'alv.result'
import Error from require 'alv.error'
import RTNode from require 'alv.rtnode'
@@ -400,6 +401,45 @@ to_evt = Constant.meta
tick: =>
@out\set @inputs.sig!
+array = Constant.meta
+ meta:
+ name: 'array'
+ summary: "Construct an array."
+ examples: { '(array a b c…)' }
+ description: "Produces an array of values."
+
+ value: do
+ any = val! / evt!
+
+ class extends PureOp
+ pattern: any!*0
+ type: (args) => Array #args, args[1]\type!
+
+ tick: =>
+ args = @unwrap_all!
+ @out\set args
+
+struct = Constant.meta
+ meta:
+ name: 'struct'
+ summary: "Construct an struct."
+ examples: { '(struct key1 val1 [key2 val2…])' }
+ description: "Produces an struct of values."
+
+ value: do
+ key = const.str / const.sym
+ val = val! / evt!
+ pair = (key + val)\named 'key', 'val'
+
+ class extends PureOp
+ pattern: pair*0
+ type: (pairs) =>
+ Struct {key.result!, val\type! for {:key, :val} in *pairs}
+
+ tick: =>
+ pairs = @unwrap_all!
+ @out\set {key, val for {:key, :val} in *pairs}
+
get = Constant.meta
meta:
name: 'get'
@@ -446,7 +486,7 @@ Scope.from_table {
'~': to_sig
'!': to_evt
- :get
+ :array, :struct, :get
true: Constant.meta
meta: