Effects: The Basics
This is where Lux gets interesting. Effects are Lux's core innovation - they make side effects explicit, controllable, and testable.
The Problem
In most languages, any function can do anything - read files, make network calls, modify global state. You can't tell from the signature. You have to read the implementation.
The Solution
In Lux, effects are declared in the type signature with with {...}:
Built-in Effects
Console- Terminal I/OFile- File system operationsHttp- HTTP requestsRandom- Random number generationTime- Time operationsState- Mutable stateFail- Error handling
When you see fn fetchUser(): User with {Http, Database}, you know this function makes HTTP calls and database queries. No surprises.
Effects propagate up the call stack. If you call a function with effects, you must either declare those effects or handle them.