fusion-lang 0.0.1.alpha1 → 0.0.1
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 +19 -6
- data/Rakefile +9 -0
- data/docs/lang/design.md +418 -28
- data/docs/lang/implementation.md +238 -0
- data/docs/lang/roadmap.md +20 -57
- data/docs/user/explanation.md +5 -10
- data/docs/user/how-to-guides.md +62 -23
- data/docs/user/reference.md +596 -168
- data/docs/user/tutorial.md +32 -29
- data/examples/double.fsn +1 -1
- data/examples/ends.fsn +4 -0
- data/examples/factorial.fsn +2 -2
- data/examples/fizzbuzz.fsn +1 -4
- data/examples/json_test.fsn +4 -0
- data/examples/palindrome.fsn +2 -1
- data/exe/fusion +17 -44
- data/lib/fusion/ast.rb +97 -0
- data/lib/fusion/atom.rb +17 -0
- data/lib/fusion/cli/decoder.rb +84 -0
- data/lib/fusion/cli/encoder.rb +28 -0
- data/lib/fusion/cli/options.rb +212 -0
- data/lib/fusion/cli/parser.rb +38 -0
- data/lib/fusion/cli/repl.rb +78 -0
- data/lib/fusion/cli/serializer.rb +70 -0
- data/lib/fusion/cli.rb +207 -0
- data/lib/fusion/interpreter/builtins.rb +465 -0
- data/lib/fusion/interpreter/env.rb +89 -0
- data/lib/fusion/interpreter/error_val.rb +71 -0
- data/lib/fusion/interpreter/func.rb +22 -0
- data/lib/fusion/interpreter/native_func.rb +22 -0
- data/lib/fusion/interpreter/thunk.rb +53 -0
- data/lib/fusion/interpreter.rb +752 -0
- data/lib/fusion/lexer.rb +249 -0
- data/lib/fusion/null.rb +9 -0
- data/lib/fusion/parser.rb +542 -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/all.fsn +13 -0
- data/stdlib/any.fsn +12 -0
- data/stdlib/chars.fsn +5 -0
- data/stdlib/compact.fsn +6 -0
- data/stdlib/concat.fsn +5 -0
- data/stdlib/falsey.fsn +6 -0
- data/stdlib/filter.fsn +12 -0
- data/stdlib/flatten.fsn +7 -0
- data/stdlib/gt.fsn +9 -0
- data/stdlib/gte.fsn +9 -0
- data/stdlib/lt.fsn +9 -0
- data/stdlib/lte.fsn +9 -0
- data/stdlib/map.fsn +6 -2
- data/stdlib/range.fsn +2 -1
- data/stdlib/reduce.fsn +8 -0
- data/stdlib/sanitize.fsn +12 -0
- data/stdlib/truthy.fsn +7 -0
- metadata +41 -2
- data/stdlib/math/square.fsn +0 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6571414d6f0a1f977f517652742c7b2766d7a17577f0276163856ff992bc7bc0
|
|
4
|
+
data.tar.gz: 1f4f3a71cbfe0a18e18e91276b0ade75ea5c49a5b9a531097b739e8f04929b24
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e4f9a32c372aea8633c1e66ab883015674d052ca83cccfab10c693f65ac805d90b4d768e1f78a4fb1a77745c158e6a39d56fa25ff9cae16cc29c765c22480ca7
|
|
7
|
+
data.tar.gz: 7feb41d65c7be52ee4a92c820edd714b8ef28b6e0c5e9a6726d1a7c41963e9f3ff4d36b7cb89afacba1256cdc675c8a4a0c5c34d6ca5865e8106f4efe70fc4c7
|
data/README.md
CHANGED
|
@@ -55,16 +55,21 @@ 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 '
|
|
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`)
|
|
62
64
|
```
|
|
63
65
|
|
|
64
|
-
- Input is read from stdin
|
|
65
|
-
- 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.
|
|
66
69
|
- The result gets printed as JSON to stdout.
|
|
67
70
|
- Errors get printed to stderr instead and set exit code `1`.
|
|
71
|
+
- How errors cross the boundary is configurable per side (`--input` / `--output`);
|
|
72
|
+
see the [reference](docs/user/reference.md) §9.4.
|
|
68
73
|
|
|
69
74
|
## Documentation
|
|
70
75
|
|
|
@@ -74,6 +79,14 @@ Refer to the [Documentation](docs/index.md) for further information.
|
|
|
74
79
|
|
|
75
80
|
After checking out the repo, run `bin/setup` to install dependencies. Run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
76
81
|
|
|
82
|
+
### Tests
|
|
83
|
+
|
|
84
|
+
```sh
|
|
85
|
+
bundle exec rspec # fast suite (default) — skips the slow specs
|
|
86
|
+
bundle exec rspec spec/cli_spec.rb # naming a slow file runs it anyway
|
|
87
|
+
bundle exec rake spec:all # everything, including the slow specs
|
|
88
|
+
```
|
|
89
|
+
|
|
77
90
|
## License
|
|
78
91
|
|
|
79
92
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
CHANGED
|
@@ -3,6 +3,15 @@
|
|
|
3
3
|
require "bundler/gem_tasks"
|
|
4
4
|
require "rspec/core/rake_task"
|
|
5
5
|
|
|
6
|
+
# task :spec (skips slow files, see .rspec)
|
|
6
7
|
RSpec::Core::RakeTask.new(:spec)
|
|
7
8
|
|
|
9
|
+
namespace :spec do
|
|
10
|
+
# task :all
|
|
11
|
+
desc "Run all specs, including the slow ones (real binary / pty)"
|
|
12
|
+
RSpec::Core::RakeTask.new(:all) do |task|
|
|
13
|
+
task.rspec_opts = "--options .rspec-ci"
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
8
17
|
task default: :spec
|