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.
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
+ )
@@ -1 +1,4 @@
1
- (n ? @Integer => [n, n] | @multiply)
1
+ (
2
+ n ? @Integer => [n, n] | @multiply,
3
+ x => !{"kind": "type_error", "location": "stdlib square.fsn", "operation": "square", "input": x | @sanitize, "message": "expected an integer"}
4
+ )
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
  )
@@ -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.alpha1
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