fix: make all example programs work correctly
- Add string concatenation support to + operator in typechecker - Register ADT constructors in both type environment and interpreter - Bind handlers as values so they can be referenced in run...with - Fix effect checking to use subset instead of exact match - Add built-in effects (Console, Fail, State) to run block contexts - Suppress dead code warnings in diagnostics, modules, parser Update all example programs with: - Expected output documented in comments - Proper run...with statements to execute code Add new example programs: - behavioral.lux: pure, idempotent, deterministic, commutative functions - pipelines.lux: pipe operator demonstrations - statemachine.lux: ADT-based state machines - tailcall.lux: tail call optimization examples - traits.lux: type classes and pattern matching Add documentation: - docs/IMPLEMENTATION_PLAN.md: feature roadmap and status - docs/PERFORMANCE_AND_TRADEOFFS.md: performance analysis Add benchmarks for performance testing. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
20
benchmarks/pattern_matching.lux
Normal file
20
benchmarks/pattern_matching.lux
Normal file
@@ -0,0 +1,20 @@
|
||||
// Benchmark: Pattern matching (measures ADT performance)
|
||||
// Tests: Constructor creation, pattern matching, recursion
|
||||
|
||||
type Tree =
|
||||
| Leaf(Int)
|
||||
| Node(Tree, Tree)
|
||||
|
||||
fn sumTree(tree: Tree): Int =
|
||||
match tree {
|
||||
Leaf(n) => n,
|
||||
Node(left, right) => sumTree(left) + sumTree(right)
|
||||
}
|
||||
|
||||
fn buildTree(depth: Int, value: Int): Tree =
|
||||
if depth <= 0 then Leaf(value)
|
||||
else Node(buildTree(depth - 1, value), buildTree(depth - 1, value + 1))
|
||||
|
||||
// Build a tree of depth 15 (32767 nodes) and sum it
|
||||
let tree = buildTree(15, 1)
|
||||
let sumResult = sumTree(tree)
|
||||
Reference in New Issue
Block a user