Docs

A compact map of the forai language: function contracts, tests, types, modules, optionals, and the CLI workflow.

FUNCTIONS + TESTS

Every 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 + OPTIONALS

Types are lightweight data declarations. Optional values use `?` to check and `!` to unwrap.
type Package
  name String
  version String
end

let pkg = Package(name: 'forai', version: '0.1.0')
let maybeName String? = null
if maybeName?
  print(maybeName!)
end

Reference Map


MODULES

A 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

CLI

The 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

FULLSTACK

Fullstack projects share one source tree. `remote def` marks server functions that client wasm calls through generated RPC stubs.
remote def currentUser
    @return User?
do
  requireSession()
end