style: auto-format example files with lux fmt
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,17 +1,8 @@
|
||||
// Demonstrating algebraic effects in Lux
|
||||
//
|
||||
// Expected output:
|
||||
// [info] Processing data...
|
||||
// [debug] Result computed
|
||||
// Final result: 42
|
||||
|
||||
// Define a custom logging effect
|
||||
effect Logger {
|
||||
fn log(level: String, msg: String): Unit
|
||||
fn getLevel(): String
|
||||
}
|
||||
|
||||
// A function that uses the Logger effect
|
||||
fn processData(data: Int): Int with {Logger} = {
|
||||
Logger.log("info", "Processing data...")
|
||||
let result = data * 2
|
||||
@@ -19,17 +10,15 @@ fn processData(data: Int): Int with {Logger} = {
|
||||
result
|
||||
}
|
||||
|
||||
// A handler that prints logs to console
|
||||
handler consoleLogger: Logger {
|
||||
fn log(level, msg) = Console.print("[" + level + "] " + msg)
|
||||
fn getLevel() = "debug"
|
||||
}
|
||||
|
||||
// Run and print
|
||||
fn main(): Unit with {Console} = {
|
||||
let result = run processData(21) with {
|
||||
Logger = consoleLogger
|
||||
}
|
||||
Logger = consoleLogger,
|
||||
}
|
||||
Console.print("Final result: " + toString(result))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user