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.
- checksums.yaml +4 -4
- data/.mutant.yml +24 -0
- data/.simplecov +11 -0
- data/CHANGELOG.md +42 -0
- data/README.md +11 -9
- data/Rakefile +8 -0
- data/docs/lang/design.md +289 -51
- data/docs/lang/implementation.md +279 -0
- data/docs/lang/roadmap.md +20 -36
- data/docs/user/explanation.md +5 -10
- data/docs/user/how-to-guides.md +145 -15
- data/docs/user/reference.md +365 -140
- data/docs/user/tutorial.md +22 -19
- data/examples/double.fsn +4 -1
- data/examples/factorial.fsn +6 -3
- data/examples/fizzbuzz.fsn +1 -4
- data/examples/gcd.fsn +9 -0
- data/examples/json_test.fsn +4 -0
- data/examples/matrix/OP.fsn +2 -0
- data/examples/matrix/average.fsn +2 -0
- data/examples/matrix/solve.fsn +2 -0
- data/examples/palindrome.fsn +1 -1
- data/exe/fusion +12 -12
- data/lib/fusion/ast.rb +76 -27
- data/lib/fusion/atom.rb +1 -1
- data/lib/fusion/cli/decoder.rb +13 -8
- data/lib/fusion/cli/encoder.rb +2 -2
- data/lib/fusion/cli/options.rb +134 -61
- data/lib/fusion/cli/parser.rb +4 -4
- data/lib/fusion/cli/repl.rb +32 -27
- data/lib/fusion/cli/serializer.rb +11 -11
- data/lib/fusion/cli.rb +120 -49
- data/lib/fusion/interpreter/builtins.rb +298 -160
- data/lib/fusion/interpreter/env.rb +42 -12
- data/lib/fusion/interpreter/error_val.rb +42 -20
- data/lib/fusion/interpreter/thunk.rb +53 -0
- data/lib/fusion/interpreter.rb +263 -98
- data/lib/fusion/lexer.rb +125 -37
- data/lib/fusion/parser.rb +245 -70
- data/lib/fusion/version.rb +3 -1
- data/lib/fusion.rb +0 -1
- data/stdlib/all.fsn +13 -0
- data/stdlib/any.fsn +12 -0
- data/stdlib/chars.fsn +5 -0
- data/stdlib/compact.fsn +5 -0
- data/stdlib/concat.fsn +6 -0
- data/stdlib/entries.fsn +6 -0
- data/stdlib/falsey.fsn +6 -0
- data/stdlib/filter.fsn +12 -0
- data/stdlib/flatten.fsn +7 -0
- data/stdlib/map.fsn +7 -4
- data/stdlib/matrix/Matrix.fsn +8 -0
- data/stdlib/matrix/OP.fsn +18 -0
- data/stdlib/matrix/add.fsn +7 -0
- data/stdlib/matrix/column.fsn +6 -0
- data/stdlib/matrix/determinant.fsn +16 -0
- data/stdlib/matrix/dimensions.fsn +5 -0
- data/stdlib/matrix/identity.fsn +6 -0
- data/stdlib/matrix/invert.fsn +26 -0
- data/stdlib/matrix/minor.fsn +15 -0
- data/stdlib/matrix/multiply.fsn +10 -0
- data/stdlib/matrix/negate.fsn +5 -0
- data/stdlib/matrix/product.fsn +11 -0
- data/stdlib/matrix/rotate.fsn +10 -0
- data/stdlib/matrix/row.fsn +6 -0
- data/stdlib/matrix/scale.fsn +6 -0
- data/stdlib/matrix/subtract.fsn +7 -0
- data/stdlib/matrix/sum.fsn +14 -0
- data/stdlib/matrix/transpose.fsn +5 -0
- data/stdlib/range.fsn +2 -2
- data/stdlib/reduce.fsn +8 -0
- data/stdlib/safe.fsn +7 -0
- data/stdlib/sanitize.fsn +2 -3
- data/stdlib/toObject.fsn +7 -0
- data/stdlib/truthy.fsn +7 -0
- data/stdlib/vector/Vector.fsn +7 -0
- data/stdlib/vector/add.fsn +6 -0
- data/stdlib/vector/cross.fsn +6 -0
- data/stdlib/vector/dot.fsn +6 -0
- data/stdlib/vector/norm.fsn +6 -0
- data/stdlib/vector/scale.fsn +5 -0
- data/stdlib/vector/subtract.fsn +6 -0
- data/stdlib/zip.fsn +6 -0
- metadata +50 -4
- data/lib/fusion/interpreter/file_thunk.rb +0 -39
- data/stdlib/mapValues.fsn +0 -5
- data/stdlib/math/square.fsn +0 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: be9bb991ddd9049b4dfbf56cd1b71395941e6836acb71272be3a72588cf80aea
|
|
4
|
+
data.tar.gz: e47c996224e5ffa767095f8be75c9c0728df566ba7463d351e065925e36cd5d7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
|
59
|
-
echo '15' | fusion examples/fizzbuzz.fsn
|
|
60
|
-
fusion
|
|
61
|
-
fusion -e '
|
|
62
|
-
printf '[
|
|
63
|
-
fusion --repl
|
|
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
|
|
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
|
-
|
|
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
|