ocaml: phase 5 HM let-rec + cons / append op types (+6 tests, 357 total)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 28s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 28s
ocaml-infer-let-rec pre-binds the function name to a fresh tv before
inferring rhs (which may recursively call the name), unifies the
inferred rhs type with the tv, generalizes, then infers body.
Builtin env types :: : 'a -> 'a list -> 'a list and @ : 'a list ->
'a list -> 'a list — needed because :op compiles to (:app (:app (:var
OP) L) R) and previously these var lookups failed.
Examples now infer:
let rec fact n = if ... in fact : Int -> Int
let rec len lst = ... in len : 'a list -> Int
let rec map f xs = ... in map : ('a -> 'b) -> 'a list -> 'b list
1 :: [2; 3] : Int list
let rec sum lst = ... in sum [1;2;3] : Int
Scoreboard refreshed: 358/358 across 14 suites.
This commit is contained in:
@@ -368,6 +368,18 @@ the "mother tongue" closure: OCaml → SX → OCaml. This means:
|
||||
|
||||
_Newest first._
|
||||
|
||||
- 2026-05-08 Phase 5 — HM let-rec inference + `::`/`@` operator types
|
||||
(+6 tests, 357 total). `ocaml-infer-let-rec` pre-binds the function
|
||||
name to a fresh tv, infers rhs (which can recursively call name),
|
||||
unifies inferred-rhs-type with the tv, generalizes, then infers
|
||||
body. Builtin env now types `:: : 'a -> 'a list -> 'a list` and
|
||||
`@ : 'a list -> 'a list -> 'a list`. Now `let rec fact …`,
|
||||
`let rec map f xs = match xs with … h :: t -> f h :: map f t`, and
|
||||
`let rec sum …` all infer correctly:
|
||||
`fact : Int -> Int`
|
||||
`len : 'a list -> Int`
|
||||
`map : ('a -> 'b) -> 'a list -> 'b list`
|
||||
`sum [1;2;3] : Int`
|
||||
- 2026-05-08 Phase 5 — HM constructor inference for option/result (+7
|
||||
tests, 351 total). `ocaml-hm-ctor-env` registers None/Some (`'a opt`),
|
||||
Ok/Error (`('a, 'b) result`). `:con NAME` instantiates the scheme;
|
||||
|
||||
Reference in New Issue
Block a user