Types & variables
Basic types
| Type | Description | Example |
|---|---|---|
int | 64-bit signed integer | 42, -1, 0 |
float | 64-bit floating point | 3.14, -0.5 |
string | UTF-8 string | "hello" |
bool | Boolean | true, false |
void | No value | (implicit for functions with no return) |
any | Dynamic type | Used by json.decode, llm.generate |
Special types
| Type | Description |
|---|---|
time | Wall-clock timestamp |
duration | Time span (30s, 24h, 7y) |
sha256 | 32-byte SHA-256 hash |
PublicKey | Ed25519 public key |
String literals
Double-quoted with escape sequences:
| Escape | Meaning |
|---|---|
\n | Newline |
\t | Tab |
\r | Carriage return |
\\ | Literal backslash |
\" | Literal double quote |
\$ | Literal dollar sign (prevents interpolation) |
String interpolation
Expressions inside ${} are evaluated and converted to strings:
let name = "Alice" let count = 3 io.println("${name} has ${count} items") // Output: Alice has 3 items io.println("total: ${items.len()}") // method calls work io.println("upper: ${strings.to_upper(name)}") // function calls work
Use \${ for a literal ${:
io.println("use \${expr} for interpolation") // Output: use ${expr} for interpolation
Variable bindings
let x = 5 // immutable, type inferred as int let y: float = 3.14 // explicit type annotation let name = "Cleat" // inferred as string
Discard binding:
let _ = some_function() // evaluate but discard the result
Structs
Named product types with typed fields:
type Point = struct { x: int, y: int, } let p = Point { x: 10, y: 20 } io.println("x = ${p.x}")
Field annotations
@description adds a hint for LLM structured output:
type Review = struct { fn">@description("Whether the code is safe to merge") approved: bool, fn">@description("Specific issues found") issues: []string, notes: string = "", // optional: excluded from JSON Schema required }
Fields with default values are excluded from the required array when the struct is used as an LLM output type. See Agents — Structured Output for details.
Enums
Named variant types:
type Severity = enum { Low, Medium, High, Critical } let s = Severity.High let label = match s { Severity.Low => "minor", Severity.High => "urgent", _ => "normal", }
When used in LLM structured output, enums generate {"type": "string", "enum": ["Low", "Medium", "High", "Critical"]} in the JSON Schema.
Slices
Ordered collections:
let xs: []int = [1, 2, 3] let names = ["alice", "bob"] // Methods xs.len() // 3 xs.contains(2) // true
Maps
Key-value collections:
let scores = map[string]int { "alice": 95, "bob": 82, } scores["charlie"] = 78 // insert/update let s = scores["alice"] // read (zero value for missing keys) // Methods scores.len() // 3 scores.contains("alice") // true scores.keys() // ["alice", "bob", "charlie"] scores.values() // [95, 82, 78] scores.remove("bob") // removes entry, returns bool // Iteration (keys) for key in scores { io.println(key) }
Result type
Result[T, E] represents either success or failure:
let ok: Result[int, string] = Ok(42) let err: Result[int, string] = Err("something went wrong")
See Error Handling for the ? operator and pattern matching.
Duration literals
Used in tool timeouts and retention annotations:
| Literal | Duration |
|---|---|
500ms | 500 milliseconds |
30s | 30 seconds |
24h | 24 hours |
7y | 7 years |