Skip to main content
Kairo’s control flow is deliberately small and explicit. You get if/else, match, return, and two local bindings (let and var). Loops are reserved but not executable in v0.1.

Local bindings

let

Immutable local binding. Cannot be reassigned.

var

Mutable local binding. Requires an explicit type.
Rules:
  • let supports type inference when the initializer type is obvious.
  • Local var requires an explicit type in v0.1.
  • let bindings cannot be reassigned; immutable members follow the same rule.

if / else

if branches on a Bool. There are no truthy or falsy coercions.
You can chain with else if:
if customer will not compile. Kairo forces you to write the check you actually mean, like if customer != null.

match

match branches on a pattern. It has two forms: statement and expression.

Statement match

Uses block arms. Good when each arm does side-effecting work.

Expression match

Uses arrow arms and returns a value. Must be exhaustive with an else arm in v0.1.
Supported v0.1 patterns:
  • Literal values (0, "paid", true)
  • Enum cases (Draft, Paid)
  • null
  • Type names
  • else
Destructuring patterns and guards are deferred.

return

return exits the current callable, optionally with a value.

Loops (reserved)

for and while are reserved keywords in v0.1. Their executable semantics are deferred until the next ratified stage.
Do not write for or while in code today. Their behavior is not ratified. Use match on enums or recursive helpers for now.

Combining with Result

match on result.isSuccess is the standard pattern for handling Result<T, E>:
See Error Handling for the full model.

Next steps

Error handling

Result<T, E> and faults.

Operators reference

Boolean, equality, comparison, and arithmetic operators.