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.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +19 -6
  3. data/Rakefile +9 -0
  4. data/docs/lang/design.md +418 -28
  5. data/docs/lang/implementation.md +238 -0
  6. data/docs/lang/roadmap.md +20 -57
  7. data/docs/user/explanation.md +5 -10
  8. data/docs/user/how-to-guides.md +62 -23
  9. data/docs/user/reference.md +596 -168
  10. data/docs/user/tutorial.md +32 -29
  11. data/examples/double.fsn +1 -1
  12. data/examples/ends.fsn +4 -0
  13. data/examples/factorial.fsn +2 -2
  14. data/examples/fizzbuzz.fsn +1 -4
  15. data/examples/json_test.fsn +4 -0
  16. data/examples/palindrome.fsn +2 -1
  17. data/exe/fusion +17 -44
  18. data/lib/fusion/ast.rb +97 -0
  19. data/lib/fusion/atom.rb +17 -0
  20. data/lib/fusion/cli/decoder.rb +84 -0
  21. data/lib/fusion/cli/encoder.rb +28 -0
  22. data/lib/fusion/cli/options.rb +212 -0
  23. data/lib/fusion/cli/parser.rb +38 -0
  24. data/lib/fusion/cli/repl.rb +78 -0
  25. data/lib/fusion/cli/serializer.rb +70 -0
  26. data/lib/fusion/cli.rb +207 -0
  27. data/lib/fusion/interpreter/builtins.rb +465 -0
  28. data/lib/fusion/interpreter/env.rb +89 -0
  29. data/lib/fusion/interpreter/error_val.rb +71 -0
  30. data/lib/fusion/interpreter/func.rb +22 -0
  31. data/lib/fusion/interpreter/native_func.rb +22 -0
  32. data/lib/fusion/interpreter/thunk.rb +53 -0
  33. data/lib/fusion/interpreter.rb +752 -0
  34. data/lib/fusion/lexer.rb +249 -0
  35. data/lib/fusion/null.rb +9 -0
  36. data/lib/fusion/parser.rb +542 -0
  37. data/lib/fusion/token.rb +22 -0
  38. data/lib/fusion/typed_data.rb +23 -0
  39. data/lib/fusion/version.rb +1 -1
  40. data/lib/fusion/wire_pair.rb +11 -0
  41. data/lib/fusion.rb +11 -1122
  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 +6 -0
  46. data/stdlib/concat.fsn +5 -0
  47. data/stdlib/falsey.fsn +6 -0
  48. data/stdlib/filter.fsn +12 -0
  49. data/stdlib/flatten.fsn +7 -0
  50. data/stdlib/gt.fsn +9 -0
  51. data/stdlib/gte.fsn +9 -0
  52. data/stdlib/lt.fsn +9 -0
  53. data/stdlib/lte.fsn +9 -0
  54. data/stdlib/map.fsn +6 -2
  55. data/stdlib/range.fsn +2 -1
  56. data/stdlib/reduce.fsn +8 -0
  57. data/stdlib/sanitize.fsn +12 -0
  58. data/stdlib/truthy.fsn +7 -0
  59. metadata +41 -2
  60. data/stdlib/math/square.fsn +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e0d1da5a83d2c41381cc04c4fd850a157469fdf91718dc306ed0ef3149ce9259
4
- data.tar.gz: 6c39994be87efa19c5a6dda7e4c61b9325dfb91b13f1a9c25999ec0435e22a09
3
+ metadata.gz: 6571414d6f0a1f977f517652742c7b2766d7a17577f0276163856ff992bc7bc0
4
+ data.tar.gz: 1f4f3a71cbfe0a18e18e91276b0ade75ea5c49a5b9a531097b739e8f04929b24
5
5
  SHA512:
6
- metadata.gz: e268696a925a14546b58fa19ab7f474fc7235b88051910ff861cb649fb6b6842ada3a62cbaf11b2f823026b86debf7431c4b95117b83b9b35f1e6f6601219cc1
7
- data.tar.gz: 539eb8f3e2f7de51f882c83aa4af6bde340aae4d4312d066ca05d7fc8151adf0a765565d1c8622d26ee2645a44e3cee3a50d8bc129562b876e58ce0c8b34eaf3
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 # => 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)
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 (or the 2nd CLI arg) as JSON and parsed into a Fusion value.
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