fusion-lang 0.0.1.alpha1 → 0.0.1.alpha2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +12 -0
- data/Rakefile +9 -0
- data/docs/lang/design.md +204 -3
- data/docs/lang/roadmap.md +1 -22
- data/docs/user/how-to-guides.md +5 -11
- data/docs/user/reference.md +342 -128
- data/docs/user/tutorial.md +11 -10
- data/examples/ends.fsn +4 -0
- data/examples/palindrome.fsn +2 -1
- data/exe/fusion +15 -42
- data/lib/fusion/ast.rb +96 -0
- data/lib/fusion/atom.rb +17 -0
- data/lib/fusion/cli/decoder.rb +79 -0
- data/lib/fusion/cli/encoder.rb +28 -0
- data/lib/fusion/cli/options.rb +142 -0
- data/lib/fusion/cli/parser.rb +38 -0
- data/lib/fusion/cli/repl.rb +73 -0
- data/lib/fusion/cli/serializer.rb +69 -0
- data/lib/fusion/cli.rb +136 -0
- data/lib/fusion/interpreter/builtins.rb +356 -0
- data/lib/fusion/interpreter/env.rb +59 -0
- data/lib/fusion/interpreter/error_val.rb +49 -0
- data/lib/fusion/interpreter/file_thunk.rb +39 -0
- data/lib/fusion/interpreter/func.rb +22 -0
- data/lib/fusion/interpreter/native_func.rb +22 -0
- data/lib/fusion/interpreter.rb +595 -0
- data/lib/fusion/lexer.rb +183 -0
- data/lib/fusion/null.rb +9 -0
- data/lib/fusion/parser.rb +404 -0
- data/lib/fusion/token.rb +22 -0
- data/lib/fusion/typed_data.rb +23 -0
- data/lib/fusion/version.rb +1 -1
- data/lib/fusion/wire_pair.rb +11 -0
- data/lib/fusion.rb +11 -1122
- data/stdlib/map.fsn +3 -1
- data/stdlib/mapValues.fsn +5 -0
- data/stdlib/math/square.fsn +4 -1
- data/stdlib/range.fsn +2 -1
- data/stdlib/sanitize.fsn +12 -0
- metadata +26 -1
data/stdlib/map.fsn
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
(
|
|
2
2
|
{"f": _, "xs": []} => [],
|
|
3
|
-
{"f": f, "xs": [x, ...rest]} => [x | f, ...({"f": f, "xs": rest} | @map)]
|
|
3
|
+
{"f": f, "xs": [x, ...rest]} => [x | f, ...({"f": f, "xs": rest} | @map)],
|
|
4
|
+
{"f": _, "xs": xs} => !{"kind": "type_error", "location": "stdlib map.fsn", "operation": "map", "input": xs | @sanitize, "message": "expected an array"},
|
|
5
|
+
x => !{"kind": "argument_error", "location": "stdlib map.fsn", "operation": "map", "input": x | @sanitize, "message": "expected {\"f\": _, \"xs\": _}"}
|
|
4
6
|
)
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# Apply f to each value of an object, keeping the keys. Input: {"f": fn, "object": obj}.
|
|
2
|
+
(
|
|
3
|
+
{"f": f, "object": obj ? @Object} => {"f": (k => [k, [obj, k] | @get | f]), "xs": obj | @keys} | @map | @toObject,
|
|
4
|
+
x => !{"kind": "argument_error", "location": "stdlib mapValues.fsn", "operation": "mapValues", "input": x | @sanitize, "message": "expected {\"f\": _, \"object\": _}"}
|
|
5
|
+
)
|
data/stdlib/math/square.fsn
CHANGED
data/stdlib/range.fsn
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
(
|
|
2
2
|
0 => [],
|
|
3
|
-
n ? @Integer => [...([n, 1] | @subtract | @range), [n, 1] | @subtract]
|
|
3
|
+
n ? (m ? @Integer => [-1, m] | @lessThan, _ => false) => [...([n, 1] | @subtract | @range), [n, 1] | @subtract],
|
|
4
|
+
x => !{"kind": "type_error", "location": "stdlib range.fsn", "operation": "range", "input": x | @sanitize, "message": "expected a non-negative integer"}
|
|
4
5
|
)
|
data/stdlib/sanitize.fsn
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Render a value safe to embed in an error payload, mirroring the interpreter's
|
|
2
|
+
# lenient serialization (docs/user/reference.md §9.3): a function becomes
|
|
3
|
+
# "<function>" and a non-finite number becomes "<Infinity>" / "<-Infinity>" /
|
|
4
|
+
# "<NaN>". Arrays and objects are sanitized recursively; everything else is
|
|
5
|
+
# returned unchanged.
|
|
6
|
+
(
|
|
7
|
+
v ? @Function => "<function>",
|
|
8
|
+
v ? @NonFinite => [["<", v | @toString] | @concat, ">"] | @concat,
|
|
9
|
+
v ? @Array => {"f": @sanitize, "xs": v} | @map,
|
|
10
|
+
v ? @Object => {"f": @sanitize, "object": v} | @mapValues,
|
|
11
|
+
v => v
|
|
12
|
+
)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fusion-lang
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.1.
|
|
4
|
+
version: 0.0.1.alpha2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Klaus Weidinger
|
|
@@ -28,16 +28,41 @@ files:
|
|
|
28
28
|
- docs/user/reference.md
|
|
29
29
|
- docs/user/tutorial.md
|
|
30
30
|
- examples/double.fsn
|
|
31
|
+
- examples/ends.fsn
|
|
31
32
|
- examples/factorial.fsn
|
|
32
33
|
- examples/first.fsn
|
|
33
34
|
- examples/fizzbuzz.fsn
|
|
34
35
|
- examples/palindrome.fsn
|
|
35
36
|
- exe/fusion
|
|
36
37
|
- lib/fusion.rb
|
|
38
|
+
- lib/fusion/ast.rb
|
|
39
|
+
- lib/fusion/atom.rb
|
|
40
|
+
- lib/fusion/cli.rb
|
|
41
|
+
- lib/fusion/cli/decoder.rb
|
|
42
|
+
- lib/fusion/cli/encoder.rb
|
|
43
|
+
- lib/fusion/cli/options.rb
|
|
44
|
+
- lib/fusion/cli/parser.rb
|
|
45
|
+
- lib/fusion/cli/repl.rb
|
|
46
|
+
- lib/fusion/cli/serializer.rb
|
|
47
|
+
- lib/fusion/interpreter.rb
|
|
48
|
+
- lib/fusion/interpreter/builtins.rb
|
|
49
|
+
- lib/fusion/interpreter/env.rb
|
|
50
|
+
- lib/fusion/interpreter/error_val.rb
|
|
51
|
+
- lib/fusion/interpreter/file_thunk.rb
|
|
52
|
+
- lib/fusion/interpreter/func.rb
|
|
53
|
+
- lib/fusion/interpreter/native_func.rb
|
|
54
|
+
- lib/fusion/lexer.rb
|
|
55
|
+
- lib/fusion/null.rb
|
|
56
|
+
- lib/fusion/parser.rb
|
|
57
|
+
- lib/fusion/token.rb
|
|
58
|
+
- lib/fusion/typed_data.rb
|
|
37
59
|
- lib/fusion/version.rb
|
|
60
|
+
- lib/fusion/wire_pair.rb
|
|
38
61
|
- stdlib/map.fsn
|
|
62
|
+
- stdlib/mapValues.fsn
|
|
39
63
|
- stdlib/math/square.fsn
|
|
40
64
|
- stdlib/range.fsn
|
|
65
|
+
- stdlib/sanitize.fsn
|
|
41
66
|
homepage: https://github.com/dunkelziffer/fusion
|
|
42
67
|
licenses:
|
|
43
68
|
- MIT
|