Functional Programming
with First-Class Effects

Effects are explicit. Types are powerful. Performance is native.

fn processOrder(
  order: Order
): Receipt
  with {Database, Email} =
{
  let saved = Database.save(order)
  Email.send(
    order.customer,
    "Order confirmed!"
  )
  Receipt(saved.id)
}

The type signature tells you everything

  • Queries the database
  • Sends an email
  • Returns a Receipt

No surprises. No hidden side effects.

EFFECTS

Side effects are tracked in the type signature. Know exactly what every function does.

TYPES

Full type inference with algebraic data types. Catch bugs at compile time.

PERFORMANCE

Compiles to native C via gcc. Matches C performance, beats Rust and Zig.

Performance

fib(35) benchmark — verified with hyperfine

Lux
28.1ms
C
29.0ms
Rust
41.2ms
Zig
47.0ms

See full methodology →

Testing Without Mocks

Swap effect handlers at test time. Same code, different behavior.

// Production
run processOrder(order) with {
  Database -> postgresDb,
  Email -> smtpServer
}
// Testing
run processOrder(order) with {
  Database -> inMemoryDb,
  Email -> collectEmails
}

Get Started

# Install via Nix
nix run github:luxlang/lux

# Or build from source
git clone https://github.com/luxlang/lux
cd lux && nix develop
cargo build --release

# Start the REPL
./target/release/lux
Full Installation Guide →