Files
lux/docs
Brandon Lucas b02807ebf4 feat: add property-based testing framework
Implements property-based testing infrastructure:

stdlib/testing.lux:
- Generators: genInt, genIntList, genString, genBool, etc.
- Shrinking helpers: shrinkInt, shrinkList, shrinkString
- Property helpers: isSorted, sameElements

examples/property_testing.lux:
- 10 property tests demonstrating the framework
- Tests for: involution, commutativity, associativity, identity
- 100 iterations per property with random inputs

docs/guide/14-property-testing.md:
- Complete guide to property-based testing
- Generator patterns and common properties
- Best practices and examples

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-16 04:39:50 -05:00
..

Lux Documentation

Lux is a functional programming language with first-class algebraic effects. It combines the safety of static typing with the flexibility of effect handlers, letting you write pure code that can do impure things—without losing control.

I want to... Go to...
Try Lux in 5 minutes Quick Start
Learn Lux systematically The Lux Guide
Understand effects Effects Guide
Look up syntax Language Reference
See the standard library Standard Library
Build something Tutorials

Quick Start

Install

# Clone and build
git clone https://github.com/your-org/lux
cd lux
cargo build --release

# Or with Nix
nix build

Hello World

Create hello.lux:

fn main(): Unit with {Console} =
    Console.print("Hello, World!")

let output = run main() with {}

Run it:

lux hello.lux
# Output: Hello, World!

The REPL

$ lux
Lux v0.1.0 - Type :help for commands

> 1 + 2 * 3
7

> fn square(x: Int): Int = x * x
<function>

> square(5)
25

> List.map([1, 2, 3], fn(x: Int): Int => x * 2)
[2, 4, 6]

What Makes Lux Different?

1. Effects Are Explicit

In most languages, a function can do anything—print, crash, launch missiles—and the type doesn't tell you. In Lux, side effects are tracked:

// This function ONLY does math—the type guarantees it
fn add(a: Int, b: Int): Int = a + b

// This function uses Console—you can see it in the signature
fn greet(name: String): Unit with {Console} =
    Console.print("Hello, " + name)

2. Effects Are Handleable

Effects aren't just tracked—they're values you can intercept and redefine:

effect Logger {
    fn log(msg: String): Unit
}

fn compute(): Int with {Logger} = {
    Logger.log("Starting")
    let result = 42
    Logger.log("Done")
    result
}

// Run with console logging
handler consoleLogger: Logger {
    fn log(msg) = {
        Console.print("[LOG] " + msg)
        resume(())
    }
}

let result = run compute() with { Logger = consoleLogger }

3. Handlers Can Resume

Unlike exceptions, effect handlers can continue the computation:

effect Ask {
    fn ask(question: String): String
}

fn survey(): Unit with {Ask, Console} = {
    let name = Ask.ask("What's your name?")
    let color = Ask.ask("Favorite color?")
    Console.print(name + " likes " + color)
}

// Handler that provides answers
handler autoAnswer: Ask {
    fn ask(q) =
        if String.contains(q, "name") then resume("Alice")
        else resume("blue")
}

run survey() with { Ask = autoAnswer }
// Output: Alice likes blue

Documentation Structure

The Lux Guide

A sequential guide to learning Lux, from basics to advanced topics.

  1. Introduction - Why Lux, installation, first program
  2. Basic Types - Int, String, Bool, functions
  3. Functions - Definitions, closures, higher-order
  4. Data Types - ADTs, pattern matching, records
  5. Effects - The core innovation
  6. Handlers - Defining and using handlers
  7. Modules - Code organization, imports
  8. Error Handling - Fail effect, Option, Result
  9. Standard Library - Built-in functions
  10. Advanced Topics - Traits, generics, optimization
  11. Databases - SQL, transactions, testing with handlers

Language Reference

Complete syntax and semantics reference.

Tutorials

Project-based learning.

Design Documents


Project Ideas

Once you've learned the basics, try building:

Beginner

  • Unit converter - Temperatures, distances, weights
  • Word counter - Count words, lines, characters in files
  • Quiz game - Random questions with scoring

Intermediate

  • Markdown parser - Parse and render Markdown
  • Task manager - CLI todo list with file persistence
  • API client - Fetch and display data from a REST API

Advanced

  • Effect-based testing framework - Use effects for test isolation
  • Configuration DSL - Effect-based config with validation
  • Interpreter - Build a small language interpreter

Showcasing Effects

  • Transactional file system - Rollback on failure using effects
  • Mock HTTP for testing - Swap real HTTP with mock handlers
  • Async simulation - Model concurrency with effect handlers
  • Capability-based security - Effects as capabilities

Philosophy

Lux is designed around these principles:

  1. Explicitness over magic - Effects in the type signature, not hidden
  2. Composition over inheritance - Effects combine freely
  3. Safety with escape hatches - Type safety by default, but practical
  4. Functional core, imperative shell - Pure logic, effectful boundaries

Getting Help

  • REPL: Type :help for commands
  • LSP: Full IDE support in VS Code, Neovim
  • Examples: See examples/ directory
  • Issues: Report bugs on GitHub

Lux: Where effects are first-class citizens.