Lambdas

Lambdas are anonymous functions. They use fn(...) -> ... inside an expression.

code
const double = fn(x: Int) -> x * 2

Lambdas can take no parameters.

code
const hello = fn() -> "Hello Donna"

They can take multiple parameters.

code
const add = fn(x: Int, y: Int) -> x + y

Lambda types use the same shape.

code
fn make_counter() -> fn(Int) -> Int:
  fn(value: Int) -> value + 1

Lambdas can capture values from their surrounding scope.

code
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.