Interactive REPL
Explore, prototype, and test ARO statements interactively without creating files or defining feature sets. The REPL provides immediate feedback with session persistence and export capabilities.
Dual-Mode Design
The REPL supports two seamless modes: Direct Mode for immediate statement execution and Feature Set Mode for defining complete feature sets interactively. Variables persist across statements within a session.
Overview
The ARO REPL (Read-Eval-Print Loop) provides an interactive environment for working with ARO. It eliminates the need to create files and define feature sets when you just want to explore how actions work, prototype a computation, or learn the language.
Internally, the REPL session acts as an implicit feature set named _repl_session_
with the business activity Interactive. All variables you define persist across
statements until you clear the session or exit.
Starting the REPL
Launch the REPL from the command line:
# Start the interactive REPL
aro repl
# Start with a file pre-loaded
aro repl --load ./my-definitions.aro
# Start with plugins available
aro repl --plugin ./Plugins/my-plugin
# Start with an HTTP server enabled
aro repl --http 8080
Command-Line Options
| Option | Description |
|---|---|
--load <file> |
Pre-load definitions from a .aro file |
--plugin <path> |
Load a plugin at startup |
--http <port> |
Start an HTTP server on the given port |
--history <file> |
Use a custom history file |
--no-color |
Disable colored output |
Direct Mode
In Direct Mode, you type ARO statements and they execute immediately. Variables persist across statements so you can build up state incrementally:
aro> Set the <name> to "Alice".
=> OK
aro> Set the <age> to 30.
=> OK
aro> Compute the <greeting> from "Hello, " ++ <name> ++ "!".
=> "Hello, Alice!"
aro> Compute the <sum> from <age> + 10.
=> 40
aro> Log "Name is ${<name>}" to the <console>.
Name is Alice
=> OK
Result Display
| Result Type | Display |
|---|---|
| Bound variable | => <value> |
| Void / OK | => OK |
| Error | Error: <message> |
| Complex object | Pretty-printed JSON |
Built-in Commands
Meta-commands start with : and control the REPL session itself.
| Command | Aliases | Description |
|---|---|---|
:help |
:h, :? |
Show help message with all commands |
:vars |
:v |
List all session variables with types and values |
:vars <name> |
Show detailed info for a specific variable | |
:type <name> |
:t |
Show the type of a variable |
:clear |
:c |
Clear all session state (variables, feature sets, history) |
:history |
:hist |
Show full input history |
:history <n> |
Show last n history entries | |
:fs |
List defined feature sets | |
:invoke <name> |
:i |
Invoke a defined feature set |
:invoke <name> <json> |
Invoke a feature set with JSON input data | |
:set <name> <value> |
Set a variable directly (accepts JSON, numbers, booleans, strings) | |
:load <file> |
Load and compile a .aro file into the session |
|
:export |
:e |
Print session as .aro code |
:export <file> |
Save session to a file | |
:export --test <file> |
Export as a test file with assertions | |
:quit |
:q, :exit |
Exit the REPL |
Variable Inspection
Use :vars to see all variables or inspect a specific one:
aro> :vars
Name Type Value
name String "Alice"
age Integer 30
user Object { name, age, ... }
aro> :vars user
user
Type: Object
Value: {
age: 30
name: "Alice"
}
aro> :type user
Object { age: Integer, name: String }
History
The :history command shows previous inputs with their status and execution time:
aro> :history 5
1. [ok] Set the <name> to "Alice". 2.0ms
2. [ok] Set the <age> to 30. 1.0ms
3. [ok] Compute the <sum> from <x> + <y>. 3.0ms
4. [err] Get the <missing> from <nowhere>.
5. [ok] Log "test" to the <console>. 1.0ms
Multiline Input
The REPL automatically detects incomplete input and continues to the next line. This triggers when it encounters:
- Unclosed braces
{, parentheses(, or brackets[ - Unclosed string literals
- A statement without a terminating
.
aro> Create the <user> with {
...> name: "Alice",
...> age: 30
...> }.
=> { name: "Alice", age: 30 }
Feature set definitions also use multiline input. The prompt changes to show the feature set name while you are inside a definition:
aro> (Calculate Tax: Finance) {
(Calculate Tax)> Extract the <amount> from the <input: value>.
(Calculate Tax)> Compute the <tax> from <amount> * 0.2.
(Calculate Tax)> Return an <OK: status> with { tax: <tax> }.
(Calculate Tax)> }
Feature set 'Calculate Tax' defined
Feature Set Mode
When you type a feature set header like (Name: Activity) {, the REPL
enters Feature Set Mode. Statements are accumulated until you close with },
then the entire feature set is compiled and registered.
Once defined, you can invoke feature sets with the :invoke command:
aro> :invoke Calculate Tax { "value": 500 }
=> { tax: 100 }
(* Or set variables first, then invoke *)
aro> :set input { "value": 100 }
=> OK
aro> :invoke Calculate Tax
=> { tax: 20 }
Use :fs to list all defined feature sets:
aro> :fs
Feature Sets:
- Calculate Tax (Finance)
- Greet User (API)
Session Export
Convert your interactive session into a proper .aro file. This is useful
for turning exploratory work into production code or tests.
Export as Feature Set
aro> Set the <base-price> to 100.
=> OK
aro> Compute the <tax> from <base-price> * 0.2.
=> 20
aro> Compute the <total> from <base-price> + <tax>.
=> 120
aro> :export
(* Generated from ARO REPL session *)
(REPL Session: Interactive) {
Set the <base-price> to 100.
Compute the <tax> from <base-price> * 0.2.
Compute the <total> from <base-price> + <tax>.
}
aro> :export ./pricing.aro
Exported to ./pricing.aro
Export as Test
The --test flag generates a test file with assertions based on the values
computed during the session:
aro> :export --test ./pricing-test.aro
Exported to ./pricing-test.aro
(* Generated content: *)
(Pricing Test: Test) {
Set the <base-price> to 100.
Assert the <base-price> is 100.
Compute the <tax> from <base-price> * 0.2.
Assert the <tax> is 20.
Compute the <total> from <base-price> + <tax>.
Assert the <total> is 120.
}
Keyboard Shortcuts
| Shortcut | Action |
|---|---|
Up / Down |
Navigate input history |
Ctrl+C |
Cancel current input |
Ctrl+D |
Exit REPL (on empty line) |
Ctrl+L |
Clear screen |
Ctrl+U |
Clear current line |
Ctrl+W |
Delete word backward |
Example Session
Here is a complete session demonstrating data processing, feature set definition, invocation, and export:
aro> Create the <scores> with [
...> { name: "Alice", score: 85 },
...> { name: "Bob", score: 92 },
...> { name: "Carol", score: 78 }
...> ].
=> OK
aro> Filter the <passing> from <scores> where score >= 80.
=> [{ name: "Alice", score: 85 }, { name: "Bob", score: 92 }]
aro> :vars
Name Type Value
scores List [3 items]
passing List [2 items]
(* Define a reusable feature set *)
aro> (Grade Report: Education) {
(Grade Report)> Filter the <passing> from <scores> where score >= 80.
(Grade Report)> Compute the <count: length> from <passing>.
(Grade Report)> Return an <OK: status> with { passing: <count> }.
(Grade Report)> }
Feature set 'Grade Report' defined
aro> :fs
Feature Sets:
- Grade Report (Education)
aro> :invoke Grade Report
=> { passing: 2 }
aro> :export ./grade-report.aro
Exported to ./grade-report.aro
aro> :quit
Learn More
See the full REPL specification in ARO-0049: Interactive REPL.