aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authors-ol <s-ol@users.noreply.github.com>2020-05-21 16:09:36 +0000
committers-ol <s+removethis@s-ol.nu>2025-03-02 14:24:49 +0000
commite5ba9645f293a975f39c9740b835be556eea06c5 (patch)
tree04072cc05dd89e2030fc23d614976195e42c692d
parentdont error when running empty files (diff)
downloadalive-e5ba9645f293a975f39c9740b835be556eea06c5.tar.gz
alive-e5ba9645f293a975f39c9740b835be556eea06c5.zip
fix some bugs
-rw-r--r--alv-lib/struct.moon4
-rw-r--r--alv/base/op.moon11
-rw-r--r--alv/base/pureop.moon12
-rw-r--r--alv/type.moon1
4 files changed, 8 insertions, 20 deletions
diff --git a/alv-lib/struct.moon b/alv-lib/struct.moon
index e30c38d..f949536 100644
--- a/alv-lib/struct.moon
+++ b/alv-lib/struct.moon
@@ -1,6 +1,6 @@
-import PureOp, Constant, T, Struct, val, evt from require 'alv.base'
+import PureOp, Constant, T, Struct, const, val, evt from require 'alv.base'
-key = val.str / val.sym
+key = const.str / const.sym
val = val! / evt!
pair = (key + val)\named 'key', 'val'
diff --git a/alv/base/op.moon b/alv/base/op.moon
index a88bbe5..b152543 100644
--- a/alv/base/op.moon
+++ b/alv/base/op.moon
@@ -2,7 +2,7 @@
-- Persistent expression Operator.
--
-- @classmod Op
-import deep_copy, deep_iter from require 'alv.util'
+import deep_copy, deep_iter, deep_map from require 'alv.util'
class Op
--- members
@@ -117,7 +117,7 @@ class Op
cur_plain = cur_val and not cur_val.__class
old_plain = old_val and not old_val.__class
- if cur_plain and old_plain
+ if cur_plain
-- both are tables, recurse
do_setup old_val, cur_val
elseif not (cur_plain or old_plain)
@@ -134,16 +134,11 @@ class Op
@inputs = inputs
do_setup old_inputs, @inputs
- do_unwrap = (value) ->
- if value.__class
- value\unwrap!
- else
- {k, do_unwrap v for k,v in pairs value}
--- `\unwrap` all `Input`s in `@inputs` and return a table with the same
-- shape.
--
-- @treturn table the values of all `Input`s
- unwrap_all: => do_unwrap @inputs
+ unwrap_all: => deep_map @inputs, (i) -> i\unwrap!
__tostring: => "<op: #{@@__name}>"
__inherited: (cls) => cls.__base.__tostring = @__tostring
diff --git a/alv/base/pureop.moon b/alv/base/pureop.moon
index 86a3235..b497914 100644
--- a/alv/base/pureop.moon
+++ b/alv/base/pureop.moon
@@ -49,18 +49,10 @@ class PureOp extends Op
if trigger
super deep_map args, (a) ->
- if a == trigger
- Input.hot trigger
- else
- Input.cold a
- -- super for a in *args
- -- if a == trigger
- -- Input.hot trigger
- -- else
- -- Input.cold a
+ Inp = if a == trigger then Input.hot else Input.cold
+ Inp a
@out = typ\mk_evt!
else
- -- super [Input.hot a for a in *args]
super deep_map args, (a) -> Input.hot a
@out or= typ\mk_sig!
diff --git a/alv/type.moon b/alv/type.moon
index 408edff..7aeb29a 100644
--- a/alv/type.moon
+++ b/alv/type.moon
@@ -96,6 +96,7 @@ class Struct extends Type
eq: (a, b) =>
return false unless (type a) == (type b)
+ return true if a == b
for key, type in pairs @types
if not type\eq a[key], b[key]
return false