Lambdas
Lambdas are anonymous functions. They use fn(...) -> ... inside an expression.
const double = fn(x: Int) -> x * 2
Lambdas can take no parameters.
const hello = fn() -> "Hello Donna"
They can take multiple parameters.
const add = fn(x: Int, y: Int) -> x + y
Lambda types use the same shape.
fn make_counter() -> fn(Int) -> Int:
fn(value: Int) -> value + 1
Lambdas can capture values from their surrounding scope.
fn add_by(amount: Int) -> fn(Int) -> Int:
fn(value: Int) -> value + amount
This makes them useful with APIs that accept function values, including pipeline-friendly helpers and web framework handlers.
Use lambdas for small local behavior. Use a named function when the behavior is reused, public, or worth documenting.