style: auto-format example files with lux fmt

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-17 06:52:44 -05:00
parent 8c90d5a8dc
commit 44ea1eebb0
54 changed files with 580 additions and 1483 deletions

View File

@@ -1,31 +1,7 @@
// Demonstrating built-in effects in Lux
//
// Lux provides several built-in effects:
// - Console: print and read from terminal
// - Fail: early termination with error
// - State: get/put mutable state (requires runtime initialization)
// - Reader: read-only environment access (requires runtime initialization)
//
// This example demonstrates Console and Fail effects.
//
// Expected output:
// Starting computation...
// Step 1: validating input
// Step 2: processing
// Result: 42
// Done!
fn safeDivide(a: Int, b: Int): Int with {Fail} = if b == 0 then Fail.fail("Division by zero") else a / b
// A function that can fail
fn safeDivide(a: Int, b: Int): Int with {Fail} =
if b == 0 then Fail.fail("Division by zero")
else a / b
fn validatePositive(n: Int): Int with {Fail} = if n < 0 then Fail.fail("Negative number not allowed") else n
// A function that validates input
fn validatePositive(n: Int): Int with {Fail} =
if n < 0 then Fail.fail("Negative number not allowed")
else n
// A computation that uses multiple effects
fn compute(input: Int): Int with {Console, Fail} = {
Console.print("Starting computation...")
Console.print("Step 1: validating input")
@@ -36,7 +12,6 @@ fn compute(input: Int): Int with {Console, Fail} = {
result
}
// Main function
fn main(): Unit with {Console} = {
let result = run compute(21) with {}
Console.print("Done!")