fusion-lang 0.0.1.alpha2 → 0.0.2

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.
Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/.mutant.yml +24 -0
  3. data/.simplecov +11 -0
  4. data/CHANGELOG.md +42 -0
  5. data/README.md +11 -9
  6. data/Rakefile +8 -0
  7. data/docs/lang/design.md +289 -51
  8. data/docs/lang/implementation.md +279 -0
  9. data/docs/lang/roadmap.md +20 -36
  10. data/docs/user/explanation.md +5 -10
  11. data/docs/user/how-to-guides.md +145 -15
  12. data/docs/user/reference.md +365 -140
  13. data/docs/user/tutorial.md +22 -19
  14. data/examples/double.fsn +4 -1
  15. data/examples/factorial.fsn +6 -3
  16. data/examples/fizzbuzz.fsn +1 -4
  17. data/examples/gcd.fsn +9 -0
  18. data/examples/json_test.fsn +4 -0
  19. data/examples/matrix/OP.fsn +2 -0
  20. data/examples/matrix/average.fsn +2 -0
  21. data/examples/matrix/solve.fsn +2 -0
  22. data/examples/palindrome.fsn +1 -1
  23. data/exe/fusion +12 -12
  24. data/lib/fusion/ast.rb +76 -27
  25. data/lib/fusion/atom.rb +1 -1
  26. data/lib/fusion/cli/decoder.rb +13 -8
  27. data/lib/fusion/cli/encoder.rb +2 -2
  28. data/lib/fusion/cli/options.rb +134 -61
  29. data/lib/fusion/cli/parser.rb +4 -4
  30. data/lib/fusion/cli/repl.rb +32 -27
  31. data/lib/fusion/cli/serializer.rb +11 -11
  32. data/lib/fusion/cli.rb +120 -49
  33. data/lib/fusion/interpreter/builtins.rb +298 -160
  34. data/lib/fusion/interpreter/env.rb +42 -12
  35. data/lib/fusion/interpreter/error_val.rb +42 -20
  36. data/lib/fusion/interpreter/thunk.rb +53 -0
  37. data/lib/fusion/interpreter.rb +263 -98
  38. data/lib/fusion/lexer.rb +125 -37
  39. data/lib/fusion/parser.rb +245 -70
  40. data/lib/fusion/version.rb +3 -1
  41. data/lib/fusion.rb +0 -1
  42. data/stdlib/all.fsn +13 -0
  43. data/stdlib/any.fsn +12 -0
  44. data/stdlib/chars.fsn +5 -0
  45. data/stdlib/compact.fsn +5 -0
  46. data/stdlib/concat.fsn +6 -0
  47. data/stdlib/entries.fsn +6 -0
  48. data/stdlib/falsey.fsn +6 -0
  49. data/stdlib/filter.fsn +12 -0
  50. data/stdlib/flatten.fsn +7 -0
  51. data/stdlib/map.fsn +7 -4
  52. data/stdlib/matrix/Matrix.fsn +8 -0
  53. data/stdlib/matrix/OP.fsn +18 -0
  54. data/stdlib/matrix/add.fsn +7 -0
  55. data/stdlib/matrix/column.fsn +6 -0
  56. data/stdlib/matrix/determinant.fsn +16 -0
  57. data/stdlib/matrix/dimensions.fsn +5 -0
  58. data/stdlib/matrix/identity.fsn +6 -0
  59. data/stdlib/matrix/invert.fsn +26 -0
  60. data/stdlib/matrix/minor.fsn +15 -0
  61. data/stdlib/matrix/multiply.fsn +10 -0
  62. data/stdlib/matrix/negate.fsn +5 -0
  63. data/stdlib/matrix/product.fsn +11 -0
  64. data/stdlib/matrix/rotate.fsn +10 -0
  65. data/stdlib/matrix/row.fsn +6 -0
  66. data/stdlib/matrix/scale.fsn +6 -0
  67. data/stdlib/matrix/subtract.fsn +7 -0
  68. data/stdlib/matrix/sum.fsn +14 -0
  69. data/stdlib/matrix/transpose.fsn +5 -0
  70. data/stdlib/range.fsn +2 -2
  71. data/stdlib/reduce.fsn +8 -0
  72. data/stdlib/safe.fsn +7 -0
  73. data/stdlib/sanitize.fsn +2 -3
  74. data/stdlib/toObject.fsn +7 -0
  75. data/stdlib/truthy.fsn +7 -0
  76. data/stdlib/vector/Vector.fsn +7 -0
  77. data/stdlib/vector/add.fsn +6 -0
  78. data/stdlib/vector/cross.fsn +6 -0
  79. data/stdlib/vector/dot.fsn +6 -0
  80. data/stdlib/vector/norm.fsn +6 -0
  81. data/stdlib/vector/scale.fsn +5 -0
  82. data/stdlib/vector/subtract.fsn +6 -0
  83. data/stdlib/zip.fsn +6 -0
  84. metadata +50 -4
  85. data/lib/fusion/interpreter/file_thunk.rb +0 -39
  86. data/stdlib/mapValues.fsn +0 -5
  87. data/stdlib/math/square.fsn +0 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4300463df5e82850cc75d27151c01a6b83e3cd66b90a5c820d40f27d54787250
4
- data.tar.gz: 044f7a4883952b56aa4336067c994ab78a7dd84e8116f68501c229414c91512e
3
+ metadata.gz: be9bb991ddd9049b4dfbf56cd1b71395941e6836acb71272be3a72588cf80aea
4
+ data.tar.gz: e47c996224e5ffa767095f8be75c9c0728df566ba7463d351e065925e36cd5d7
5
5
  SHA512:
6
- metadata.gz: 0d0cd98c87c04c9cc88694ad3d4e926103334fd03d5bfadcf147050c41f63bdb17b4b1bfaad9a5cd9bc456d5ea3ec17ded24db02e4d83d4035d1f403d4d669d6
7
- data.tar.gz: 38d2637d43d8cbc5c17423a329e64605cde2cb2d154207174ec482611df43b1bc1f5d8435bd1bda751528bdc4a7d029b751b0e5f3fa11d10731afe82044b745a
6
+ metadata.gz: fa9b652f9f19d74561245a6948726ecef900ff4e40ba2fd3d8fda66f36cf68a0fc54fc7369ee78094794a083a6519c78751c4e0c8b5b3cd7cf1a99cfca55ff00
7
+ data.tar.gz: 66cc3557d141785c1075f3483c894140bb7d94c9fa8634a069713b84b00c72ae3852e395637d750e4da0486079fad96edd378677e8070b811f2500e39220763a
data/.mutant.yml ADDED
@@ -0,0 +1,24 @@
1
+ ---
2
+ requires:
3
+ - ./lib/fusion
4
+
5
+ integration:
6
+ name: rspec
7
+ # Optional per integration arguments. Proxies through to the integrations native CLI processor.
8
+ # Currently for minitest integration arguments are ignored.
9
+ # Note that when set this *OVERWRITES* the hardcoded defaults mutant provides. So should you
10
+ # provide your own arguments, for rspec you *need* to specify the `spec` directory at a minimum.
11
+ # Mutant is not compatible with many rspec options, take care you do not violate mutants invariants.
12
+ # During CLI executions you can manually add new integration arguments via `--integration-argument`,
13
+ # you have to specify it once per argument, so: `--integration-argument seed --integration-argument 0`
14
+ # would execute rspec with the `--seed 0` flag.
15
+ # Below shows an example configuring rspec to use a static seed from the config file.
16
+ arguments:
17
+ - --fail-fast # rspec integration default, keep this when specifying manual options!
18
+ - --options
19
+ - .rspec-ci
20
+ - spec # spec directory
21
+
22
+ matcher:
23
+ subjects:
24
+ - Fusion*
data/.simplecov ADDED
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Central SimpleCov configuration, shared by
4
+ # - the in-process suite (spec/spec_helper.rb)
5
+ # - the subprocesses spawned to drive the real binary (spec/simplecov_spawn.rb)
6
+ SimpleCov.configure do
7
+ enable_coverage :branch
8
+
9
+ add_group "Fusion", "lib/"
10
+ add_group "Tests", "spec/"
11
+ end
data/CHANGELOG.md ADDED
@@ -0,0 +1,42 @@
1
+ # Changelog
2
+
3
+ This project adheres to [Break Versioning](https://www.taoensso.com/break-versioning).
4
+
5
+ ## [Unreleased]
6
+
7
+ ### Breaking
8
+
9
+ - The stdlib functions `@lt`, `@lte`, `@gt`, `@gte` have been turned into builtins
10
+ and moved into the `@OP` object. Migration:
11
+ - `@lt` -> `@OP.lt`
12
+ - `@lte` -> `@OP.lte`
13
+ - `@gt` -> `@OP.gt`
14
+ - `@gte` -> `@OP.gte`
15
+ Their errors now report `"origin": "builtin"`.
16
+ - The builtin `@toObject` has been moved to the stdlib. Its regular behavior stayed
17
+ the same, but its errors now report `"origin": "stdlib"`.
18
+ - The `expected` strings of many error payloads have been improved. Consumers that
19
+ matched the exact `expected` text need to update.
20
+ - The stdlib function `@concat` has been extended to be n-ary. Consumers that relied
21
+ on an error if the number of given strings wasn't equal to 2 need to update.
22
+
23
+ ### Non-breaking
24
+
25
+ - New syntax sugar has been introduced:
26
+ - `a < b` is `[a, b] | @OP.compare | @OP.lt`
27
+ - `a <= b` is `[a, b] | @OP.compare | @OP.lte`
28
+ - `a > b` is `[a, b] | @OP.compare | @OP.gt`
29
+ - `a >= b` is `[a, b] | @OP.compare | @OP.gte`
30
+ - New builtin predicates:
31
+ - `@Collection`: true for arrays and objects.
32
+ - New stdlib functions:
33
+ - `@entries`: an object's `[key, value]` pairs, the inverse of `@toObject`.
34
+ - `@zip`: turns a pair of equal-length arrays into an array of `[left, right]` pairs.
35
+ - `@safe`: the error catcher `(! => false, v => v)`
36
+ - New stdlib modules:
37
+ - `matrix/` (including the matrix operator set `@matrix/OP`)
38
+ - `vector/`
39
+
40
+ ## [0.0.1] - 2026-07-04
41
+
42
+ Release the first non-alpha version of Fusion.
data/README.md CHANGED
@@ -55,16 +55,17 @@ gem "fusion-lang", require: "fusion"
55
55
  ## How to run your code
56
56
 
57
57
  ```sh
58
- echo '5' | fusion examples/factorial.fsn # => 120
59
- echo '15' | fusion examples/fizzbuzz.fsn # => "FizzBuzz"
60
- fusion examples/factorial.fsn 5 # => 120 (input as an argument)
61
- fusion -e '(n => [n,2] | @multiply)' 21 # => 42 (inline program)
62
- printf '[1, 2]\n[3, 4]\n' | fusion --stream examples/double.fsn # => [2,4] [6,8] (NDJSON, one value per line)
63
- fusion --repl # interactive expressions and `name = expression`
58
+ echo '5' | fusion examples/factorial.fsn # => 120
59
+ echo '15' | fusion examples/fizzbuzz.fsn # => "FizzBuzz"
60
+ echo '21' | fusion -e '(n => [n,2] | @OP.product)' # => 42 (inline program)
61
+ fusion -e '[1, [2, 3] | @OP.sum]' # => [1,5] (no input: the program's value is the result)
62
+ printf '[0,3]\n[0,4]\n' | fusion --stream examples/double.fsn # => [0,6] [0,8] (NDJSON, array mode)
63
+ fusion --repl # interactive REPL (also started by a bare `fusion`)
64
64
  ```
65
65
 
66
- - Input is read from stdin (or the 2nd CLI arg) as JSON and parsed into a Fusion value.
67
- - The file's function gets applied to this value: `value | function`
66
+ - Input is read from stdin as JSON and parsed into a Fusion value.
67
+ - The file's function gets applied to this value: `value | function`.
68
+ - With no input, the file's own value is the result — so a `.fsn` file doubles as enriched JSON data.
68
69
  - The result gets printed as JSON to stdout.
69
70
  - Errors get printed to stderr instead and set exit code `1`.
70
71
  - How errors cross the boundary is configurable per side (`--input` / `--output`);
@@ -76,7 +77,8 @@ Refer to the [Documentation](docs/index.md) for further information.
76
77
 
77
78
  ## Development
78
79
 
79
- After checking out the repo, run `bin/setup` to install dependencies. Run `bin/console` for an interactive prompt that will allow you to experiment.
80
+ - Run `bundle install` to install dependencies.
81
+ - Run `bin/console` for an interactive prompt that will allow you to experiment.
80
82
 
81
83
  ### Tests
82
84
 
data/Rakefile CHANGED
@@ -12,6 +12,14 @@ namespace :spec do
12
12
  RSpec::Core::RakeTask.new(:all) do |task|
13
13
  task.rspec_opts = "--options .rspec-ci"
14
14
  end
15
+
16
+ desc "Run mutation testing"
17
+ task :mutant do
18
+ command = "bundle exec mutant run --usage opensource"
19
+ # On CI, let mutant use all available cores.
20
+ command += " --jobs 8" unless ENV["CI"]
21
+ sh command
22
+ end
15
23
  end
16
24
 
17
25
  task default: :spec