Write comprehensive PHILOSOPHY.md covering Lux's six core principles (explicit over implicit, composition over configuration, safety without ceremony, practical over academic, one right way, tools are the language) with detailed comparisons against JS/TS, Python, Rust, Go, Java/C#, Haskell/Elm, and Gleam/Elixir. Includes tooling audit and improvement suggestions. Add `lux philosophy` command to the compiler, update help screen with abbreviated philosophy, and link from README. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Quick Links
| 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.
- Introduction - Why Lux, installation, first program
- Basic Types - Int, String, Bool, functions
- Functions - Definitions, closures, higher-order
- Data Types - ADTs, pattern matching, records
- Effects - The core innovation
- Handlers - Defining and using handlers
- Modules - Code organization, imports
- Error Handling - Fail effect, Option, Result
- Standard Library - Built-in functions
- Advanced Topics - Traits, generics, optimization
- Databases - SQL, transactions, testing with handlers
Language Reference
Complete syntax and semantics reference.
- Syntax - Grammar and syntax rules
- Standard Library - Built-in functions and modules
Tutorials
Project-based learning.
- Calculator - Basic REPL calculator
- Dependency Injection - Testing with effects
- Project Ideas - Ideas for building with Lux
Design Documents
- Packages - Package manager and dependencies
- SQL Design Analysis - SQL as built-in vs package
- Roadmap - Development priorities and status
- Website Plan - Website architecture and content
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:
- Explicitness over magic - Effects in the type signature, not hidden
- Composition over inheritance - Effects combine freely
- Safety with escape hatches - Type safety by default, but practical
- Functional core, imperative shell - Pure logic, effectful boundaries
Getting Help
- REPL: Type
:helpfor 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.