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

Use lambdas for small local behavior. Use a named function when the behavior is reused, public, or worth documenting.