-
Notifications
You must be signed in to change notification settings - Fork 0
Reference Statements
This document provides a complete reference for all statement types in ARO.
The fundamental statement type following the Action-Result-Object pattern.
Action [article] <result> preposition [article] <object> [modifiers].
| Component | Required | Description |
|---|---|---|
| Action | Yes | Plain action verb (no angle brackets) |
| Article | No | a, an, or the |
| Result | Yes | Output variable |
| Preposition | Yes | Relationship word |
| Object | Yes | Input/target |
| Modifiers | No | where, with, on, when clauses |
Extract the <user-id> from the <request: parameters>.
Create a <user> with <user-data>.
Return an <OK: status> for the <request>.
Store the <order> into the <order-repository>.
Retrieve the <user> from the <repository> where id = <user-id>.
Start the <http-server> on port 8080.
Makes a variable globally accessible across feature sets.
Publish as <alias> <variable>.
| Component | Description |
|---|---|
| alias | Name to publish under |
| variable | Variable to publish |
Read the <config> from the <file: "./config.json">.
Publish as <app-config> <config>.
Conditionally executes a statement based on a condition. If the condition is false, the statement is skipped.
Action the <result> preposition the <object> when <condition>.
| Condition | Description |
|---|---|
<var> is <value> |
Equality |
<var> is not <value> |
Inequality |
<var> is empty |
Null/empty check |
<var> is not empty |
Has value |
<var> exists |
Value exists |
<var> is null |
Null check |
<var> > <value> |
Greater than |
<var> < <value> |
Less than |
<var> >= <value> |
Greater or equal |
<var> <= <value> |
Less or equal |
<cond1> and <cond2> |
Both true |
<cond1> or <cond2> |
Either true |
not <cond> |
Negation |
(* Return not found only when user is empty *)
Return a <NotFound: status> for the <missing: user> when <user> is empty.
(* Send notification only when user has email *)
Send the <notification> to the <user: email> when <user: email> exists.
(* Log admin access only for admins *)
Log <admin-access> to the <audit> when <user: role> = "admin".
(* Early exit on invalid input *)
Return a <BadRequest: status> for the <invalid: amount> when <amount> <= 0.
(* Combined conditions *)
Grant the <access> for the <user> when <user: active> is true and <user: verified> is true.
(PUT /users/{id}: User API) {
Extract the <user-id> from the <request: parameters>.
Extract the <updates> from the <request: body>.
(* Early exit guards *)
Return a <BadRequest: status> for the <missing: id> when <user-id> is empty.
Return a <BadRequest: status> for the <missing: data> when <updates> is empty.
(* Continue with valid input *)
Retrieve the <user> from the <repository> where id = <user-id>.
Return a <NotFound: status> for the <missing: user> when <user> is empty.
Transform the <updated-user> from the <user> with <updates>.
Store the <updated-user> into the <repository>.
Return an <OK: status> with <updated-user>.
}
Pattern matching for multiple cases.
match <variable> {
case <value1> {
(* statements *)
}
case <value2> {
(* statements *)
}
otherwise {
(* fallback statements *)
}
}
match <variable> {
case <value> where <condition> {
(* statements *)
}
}
match <status> {
case "pending" {
Log "Order is pending" to the <console>.
}
case "shipped" {
Log "Order has shipped" to the <console>.
Emit an <OrderShipped: event> with <order>.
}
case "delivered" {
Log "Order delivered" to the <console>.
Emit an <OrderDelivered: event> with <order>.
}
otherwise {
Log "Unknown status" to the <console>.
}
}
match <user: subscription> {
case <premium> where <user: credits> > 0 {
Grant the <premium-features> for the <user>.
Deduct the <credit> from the <user: account>.
}
case <premium> {
Notify the <user> about the <low-credits>.
Grant the <basic-features> for the <user>.
}
case <basic> {
Grant the <basic-features> for the <user>.
}
otherwise {
Redirect the <user> to the <subscription-page>.
}
}
Exits the feature set with a response.
Return [article] <status> [with <data>] [for <context>].
| Status | HTTP Code | Usage |
|---|---|---|
OK |
200 | Successful request |
Created |
201 | Resource created |
Accepted |
202 | Async operation started |
NoContent |
204 | Success, no body |
BadRequest |
400 | Invalid input |
Unauthorized |
401 | Auth required |
Forbidden |
403 | Access denied |
NotFound |
404 | Not found |
Conflict |
409 | Resource conflict |
UnprocessableEntity |
422 | Validation failed |
TooManyRequests |
429 | Rate limited |
InternalError |
500 | Server error |
ServiceUnavailable |
503 | Service down |
Return an <OK: status> with <data>.
Return a <Created: status> with <resource>.
Return a <NoContent: status> for the <deletion>.
Return a <BadRequest: status> with <validation: errors>.
Return a <NotFound: status> for the <missing: user>.
Return a <Forbidden: status> for the <unauthorized: access>.
Adds documentation to code.
(* comment text *)
(* This is a single-line comment *)
(*
This is a
multi-line comment
*)
(* Comments can be (* nested *) *)
(Process Order: Order Processing) {
(* Extract order data from request *)
Extract the <order-data> from the <request: body>.
(* Validate before processing *)
Validate the <order-data> for the <order-schema>.
(* Store and return *)
Store the <order> into the <repository>.
Return a <Created: status> with <order>.
}
Filters data in retrieval and deletion.
... where <field> = <value>
... where <field> = <value> and <field2> = <value2>
Retrieve the <user> from the <repository> where id = <user-id>.
Retrieve the <orders> from the <repository> where status = "pending".
Retrieve the <users> from the <repository> where role = "admin" and active = true.
Delete the <sessions> from the <repository> where userId = <user-id>.
Provides additional data or parameters.
... with <variable>
... with <object-literal>
... with <string-literal>
Create the <user> with <user-data>.
Create the <config> with { debug: true, port: 8080 }.
Transform the <updated> from the <user> with <updates>.
Send the <message> to the <connection> with "Hello, World!".
Log "Application started" to the <console>.
Specifies ports for network operations.
... on port <number>
Start the <http-server> on port 8080.
Listen on port 9000 as <socket-server>.
Connect to <host: "localhost"> on port 5432 as <database>.
Conditionally executes a statement.
Action the <result> preposition the <object> when <condition>.
Return a <NotFound: status> for the <user> when <user> is empty.
Log "Low stock" to the <console> when <stock> < 10.
Send the <alert> to the <admin: email> when <errors> > <threshold>.
Statements execute sequentially from top to bottom:
(Process Request: Handler) {
(* 1. First *)
Extract the <data> from the <request: body>.
(* 2. Second *)
Validate the <data> for the <schema>.
(* 3. Third *)
Create the <result> with <data>.
(* 4. Fourth *)
Store the <result> into the <repository>.
(* 5. Fifth - ends execution *)
Return a <Created: status> with <result>.
(* Never executed - after return *)
Log "This won't run" to the <console>.
}
All statements end with a period (.):
(* Correct *)
Extract the <data> from the <request>.
Return an <OK: status> with <data>.
(* Incorrect - missing period *)
Extract the <data> from the <request>
Match blocks use braces without periods on closing brace:
match <status> {
case "active" {
Return an <OK: status>. (* Period on inner statement *)
}
} (* No period on closing brace *)
Fundamentals
- The Basics
- Feature Sets
- Actions
- Variables
- Type System
- Control Flow
- Error Handling
- Computations
- Dates
- Concurrency
Runtime & Events
I/O & Communication
Advanced