haskell: Phase 17 — expression type annotations (x :: Int) (parse + desugar pass-through)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 56s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 56s
Parser hk-parse-parens gains a `::` arm after the first inner expression: consume `::`, parse a type via the existing hk-parse-type, expect `)`, emit (:type-ann EXPR TYPE). Sections, tuples, parenthesised expressions and unit `()` are unchanged. Desugar drops the annotation — :type-ann E _ → (hk-desugar E) — since the existing eval path has no type-directed dispatch. Phase 20 will extend infer.sx to consume the annotation and unify against the inferred type. tests/parse-extras.sx (12/12) covers literal, arithmetic, function arg, string, bool, tuple, nested annotation, function-typed annotation, and no-regression checks for plain parens / 3-tuples / left+right sections. eval (66/0), exceptions (14/0), typecheck (15/0), records (14/0), ioref (13/0) all still clean. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -316,7 +316,7 @@ No OCaml changes are needed. The view type is fully representable as an SX dict.
|
||||
Real Haskell programs use these on every page; closing the gaps unblocks
|
||||
larger conformance programs and removes one-line workarounds in test sources.
|
||||
|
||||
- [ ] Type annotations in expressions: `(x :: Int)`, `f (1 :: Int)`,
|
||||
- [x] Type annotations in expressions: `(x :: Int)`, `f (1 :: Int)`,
|
||||
`return (42 :: Int)`. Parser currently rejects `::` in `aexp` position;
|
||||
desugar should drop the annotation (we have no inference at this layer
|
||||
yet, so it's a parse-only pass-through).
|
||||
@@ -420,6 +420,15 @@ constraints (qualified types `[ClassName var] => type`).
|
||||
|
||||
_Newest first._
|
||||
|
||||
**2026-05-08** — Phase 17 first box: expression type annotations `(x :: Int)`,
|
||||
`f (1 :: Int)`, `(\x -> x+1) :: Int -> Int`. Parser's `hk-parse-parens`
|
||||
gains a `::` arm after the first inner expression: consume `::`, parse a
|
||||
type via the existing `hk-parse-type`, expect `)`, emit `(:type-ann EXPR
|
||||
TYPE)`. Desugar drops the annotation — `:type-ann E _ → (hk-desugar E)` —
|
||||
since the existing eval path has no type-directed dispatch; Phase 20 will
|
||||
let inference consume the annotation. tests/parse-extras.sx 12/12; eval,
|
||||
exceptions, typecheck, records, ioref still clean.
|
||||
|
||||
**2026-05-08** — Plan extends with Phases 20-22 (HM type system). Discovered
|
||||
during planning that `lib/haskell/infer.sx` already lands core Algorithm W
|
||||
(75 inference unit tests pass; let-polymorphism, sig checking, error
|
||||
|
||||
Reference in New Issue
Block a user