fusion-lang 0.0.1.alpha1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: e0d1da5a83d2c41381cc04c4fd850a157469fdf91718dc306ed0ef3149ce9259
4
+ data.tar.gz: 6c39994be87efa19c5a6dda7e4c61b9325dfb91b13f1a9c25999ec0435e22a09
5
+ SHA512:
6
+ metadata.gz: e268696a925a14546b58fa19ab7f474fc7235b88051910ff861cb649fb6b6842ada3a62cbaf11b2f823026b86debf7431c4b95117b83b9b35f1e6f6601219cc1
7
+ data.tar.gz: 539eb8f3e2f7de51f882c83aa4af6bde340aae4d4312d066ca05d7fc8151adf0a765565d1c8622d26ee2645a44e3cee3a50d8bc129562b876e58ce0c8b34eaf3
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2026 Klaus Weidinger
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,79 @@
1
+ # Fusion
2
+
3
+ The reference implementation of the Fusion language.
4
+
5
+ > :warning: This project is in an Alpha stage and still subject to rapid and unannounced breaking changes.
6
+
7
+ **Fusion** is a small programming language. It is "functional JSON". It is JSON's data
8
+ model (atomic values, arrays, objects) plus one more ingredient, the function. Functions take
9
+ one input and one output and work by pattern-matching.
10
+
11
+ ## Elevator pitch - a 1-minute taste of the ideas
12
+
13
+ **A file is one value**:
14
+ - A program is simply a file containing a single function.
15
+ - Executing it means evaluating `STDIN | thatFunction`.
16
+ - Regular result values get printed to `STDOUT`.
17
+ - Errors get printed to `STDERR` and set exit code `1`.
18
+
19
+ **Pattern matching is the only control flow**:
20
+ - Pattern matching is a better `if` statement.
21
+ - A `for` loop is recursion on lists.
22
+
23
+ **Bare words are holes**:
24
+ - They bind in patterns and read in results
25
+ - So a pattern and a result are mirror images: `([a, b] => [b, a])` swaps a pair.
26
+
27
+ **Types are predicates**:
28
+ - `n ? @Integer` matches only integers.
29
+ - `@Integer` is just a built-in function and you could use any of your own functions as well.
30
+
31
+ **Errors have payloads**:
32
+ - An error is `!` followed by a payload value (e.g. `!"divide by zero"`, `!42`, `!{"kind":"missing_key",...}`).
33
+ - Errors propagate unless caught with an error pattern like `!msg`, `!42`, or just `!`.
34
+ - Pattern matching works the same way on error payloads as on regular values.
35
+
36
+ **One `@` namespace for everything**:
37
+ - `@name` can access a sibling file `name.fsn`, a standard library file `$STDLIB_DIR/name.fsn` or the builtin `name`.
38
+ - Sibling files can shadow the standard library and builtins.
39
+ - A bare `@` refers to the current file for easier recursion.
40
+ - `@ENV` allows read access to environment variables.
41
+ - `name | @load` loads a file by name. Useful for dynamic file access or file names with special characters.
42
+
43
+ ## Installation
44
+
45
+ To use **Fusion** as a real scripting language, install it globally on your system:
46
+ ```bash
47
+ gem install fusion-lang
48
+ ```
49
+
50
+ To use any `Fusion` modules from another Ruby program, add it to your `Gemfile`:
51
+ ```ruby
52
+ gem "fusion-lang", require: "fusion"
53
+ ```
54
+
55
+ ## How to run your code
56
+
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
+ ```
63
+
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
+ - The result gets printed as JSON to stdout.
67
+ - Errors get printed to stderr instead and set exit code `1`.
68
+
69
+ ## Documentation
70
+
71
+ Refer to the [Documentation](docs/index.md) for further information.
72
+
73
+ ## Development
74
+
75
+ 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
+
77
+ ## License
78
+
79
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
data/docs/index.md ADDED
@@ -0,0 +1,34 @@
1
+ # Fusion documentation
2
+
3
+ ## How this documentation is organised
4
+
5
+ The user documentation follows the [Diátaxis](https://diataxis.fr/) system, which
6
+ separates documentation into four kinds by the need each serves. Pick the one that
7
+ matches what you want right now:
8
+
9
+ | If you want to… | Read | Diataxis categories |
10
+ | -------------------------------------------------- | -------------------------------------- | ------------------- |
11
+ | **learn** the language from scratch | [Tutorial](user/tutorial.md) | study / action |
12
+ | **accomplish a specific task** you already have | [How-to guides](user/how-to-guides.md) | apply / action |
13
+ | **look up** exact syntax, built-ins, and behavior | [Reference](user/reference.md) | apply / cognition |
14
+ | **understand why** the language is shaped this way | [Explanation](user/explanation.md) | study / cognition |
15
+
16
+ Keeping these separate is deliberate:
17
+ - A recipe should not digress into theory.
18
+ - A reference should not try to teach.
19
+
20
+ If you are new to this language, start with the [Tutorial](user/tutorial.md).
21
+
22
+ ## Design documentation
23
+
24
+ Separate from the user docs and mostly aimed at language designers and contributors rather
25
+ than users:
26
+
27
+ - **[Design documentation](lang/design.md)** — the full decision ledger: every
28
+ design choice, who made it (designer vs. interpreter implementation), the
29
+ alternatives considered, and the pros and cons.
30
+ - **[Roadmap](lang/roadmap.md)** — planned ergonomics, open questions,
31
+ and bigger experiments.
32
+
33
+ These are the places to understand what the language is and what is still
34
+ unfinished.