Types & variables

Basic types

TypeDescriptionExample
int64-bit signed integer42, -1, 0
float64-bit floating point3.14, -0.5
stringUTF-8 string"hello"
boolBooleantrue, false
voidNo value(implicit for functions with no return)
anyDynamic typeUsed by json.decode, llm.generate

Special types

TypeDescription
timeWall-clock timestamp
durationTime span (30s, 24h, 7y)
sha25632-byte SHA-256 hash
PublicKeyEd25519 public key

String literals

Double-quoted with escape sequences:

EscapeMeaning
\nNewline
\tTab
\rCarriage return
\\Literal backslash
\"Literal double quote
\$Literal dollar sign (prevents interpolation)

String interpolation

Expressions inside ${} are evaluated and converted to strings:

cleat
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 ${:

cleat
io.println("use \${expr} for interpolation")
// Output: use ${expr} for interpolation

Variable bindings

cleat
let x = 5          // immutable, type inferred as int
let y: float = 3.14  // explicit type annotation
let name = "Cleat"  // inferred as string

Discard binding:

cleat
let _ = some_function()  // evaluate but discard the result

Structs

Named product types with typed fields:

cleat
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:

cleat
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:

cleat
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:

cleat
let xs: []int = [1, 2, 3]
let names = ["alice", "bob"]

// Methods
xs.len()           // 3
xs.contains(2)     // true

Maps

Key-value collections:

cleat
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:

cleat
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:

LiteralDuration
500ms500 milliseconds
30s30 seconds
24h24 hours
7y7 years
Edit this page on GitHub