diff --git a/plans/haskell-on-sx.md b/plans/haskell-on-sx.md index 8ef83b43..a074ccbf 100644 --- a/plans/haskell-on-sx.md +++ b/plans/haskell-on-sx.md @@ -86,9 +86,9 @@ Key mappings: - [x] `sieve.hs` — lazy sieve of Eratosthenes - [x] `quicksort.hs` — naive QS - [x] `nqueens.hs` - - [ ] `calculator.hs` — parser combinator style expression evaluator + - [x] `calculator.hs` — parser combinator style expression evaluator - [ ] `lib/haskell/conformance.sh` + runner; `scoreboard.json` + `scoreboard.md` -- [ ] Target: 5/5 classic programs passing +- [x] Target: 5/5 classic programs passing ### Phase 4 — Hindley-Milner inference - [ ] Algorithm W: unification + type schemes + generalisation + instantiation @@ -114,6 +114,15 @@ Key mappings: _Newest first._ +- **2026-04-25** — Classic program `calculator.hs`: recursive descent + expression evaluator using ADTs for tokens and results. + `data Token = TNum Int | TOp String` + `data Result = R Int [Token]`; + parser threads token lists through `R` constructors enabling nested + constructor pattern matching (`R v (TOp "+":rest)`). Handles two-level + operator precedence (* / tighter than + −) and left-associativity. + 5 tests: addition, precedence, left-assoc subtraction, left-assoc + div+mul, single number. All 5 classic programs complete. 402/402 green. + - **2026-04-25** — Classic program `nqueens.hs`: backtracking n-queens via list comprehension and multi-clause `where`. Three fixes needed: (1) `hk-eval-let` now delegates to `hk-bind-decls!` so multi-clause `where`/`let` bindings