DocsA compact map of the forai language: function contracts, tests, types, modules, optionals, and the CLI workflow.
FUNCTIONS + TESTSEvery named function documents its contract, then proves behavior with a nearby test block.# Compute an area.
def area
@param width Float
@param height Float
@return Float
do
width * height
end
test area
it 'multiplies dimensions'
assert.equals(area(3.0, 4.0), 12.0)
end
end
TYPES + OPTIONALSTypes are lightweight data declarations. Optional values use `?` to check and `!` to unwrap.type Task
id Int
text String
done Bool
end
let task = Task(id: 1, text: 'ship', done: false)
let maybeName String? = null
if maybeName?
print(maybeName!)
end
Reference Map
MODULESA directory is a module. Import by directory name, and import every UFCS modifier explicitly from its module.use { HomePage } from pages.home
use { Label, padding } from Forui.view
CLIThe pipeline is fmt, check, test, then run or build. Failing checks stop the command early.fai fmt
fai check
fai test
fai run
fai build
fai doc std.string
FULLSTACKFullstack projects share one source tree. `remote def` marks server functions that client wasm calls through generated RPC stubs.remote def getTasks
@return Task[]
do
requireSession()
...
end