Algebraic effects
Effects visible in the type, composable handlers. No async/await infecting the whole call stack.
A functional language with algebraic effects and isolated fibers. No garbage collector, no borrow checker.
Designed to be written with — and by — agents.
effect Log {
log(msg: String) : Unit
}
fn greet(name: String) : Unit / Log {
Log.log("hello, #{name}")
}
fn main() {
handle {
greet("kaikai")
greet("world")
} with Log {
log(msg, resume) -> {
println("[INFO] #{msg}")
resume(())
}
}
}Effects visible in the type, composable handlers. No async/await infecting the whole call stack.
Four operators, four intents: |> applies, | maps, || flat-maps, |? filters. Each form tells you what it does before you read the function.
Perceus reference counting + isolated fibers. Memory is per-fiber; no global pauses.
Real<m/s> for measures, currencies that never mix, arenas via region { }. Information in the type, zero runtime cost.
requires, ensures, Int where >= 0. What SPARK does, without an SMT solver.
Holes (?), --holes-json, structured diagnostics. Designed for humans and agents to write together.
A whole program and what it prints. This one chains all four pipes over a range to sum the even squares.
fn square(n: Int) : Int = n * n
fn divisors(n: Int) : [Int] = [1, n]
fn is_even(n: Int) : Bool = n % 2 == 0
fn main() {
# `[1..4]` is a range literal — no hand-written accumulator loop.
# `[1..10..2]` adds a step.
let total = [1..4] # [1, 2, 3, 4]
| square # [1, 4, 9, 16] (map)
|| divisors # [1, 1, 1, 4, 1, 9, 1, 16] (flat-map)
|? is_even # [4, 16] (filter)
|> list.sum # 20 (apply)
println("total=#{total}")
}$ kai run 06_pipes.kaitotal=20