ocaml: phase 5 HM let-mut / let-rec-mut (+3 tests, 442 total)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 30s

ocaml-infer-let-mut: each rhs inferred in parent env, generalized
sequentially before adding to body env.

ocaml-infer-let-rec-mut: pre-bind all names with fresh tvs; infer
each rhs against the joint env, unify each with its tv, then
generalize all and infer body.

Mutual recursion now type-checks:
  let rec even n = if n = 0 then true else odd (n - 1)
  and odd n = if n = 0 then false else even (n - 1)
  in even   : Int -> Bool
This commit is contained in:
2026-05-08 17:28:27 +00:00
parent 4909ebe2ad
commit cabf5dc9c3
3 changed files with 111 additions and 0 deletions

View File

@@ -399,6 +399,12 @@ _Newest first._
recognise `!` as the prefix-deref of an application argument, so
`String.concat "" (List.rev !b)` parses as `(... (deref b))`. Buffer
uses a ref holding a string list; contents reverses and concats.
- 2026-05-08 Phase 5 — HM let-mut / let-rec-mut inference (+3 tests,
442 total). `ocaml-infer-let-mut` infers each rhs in the parent env
and generalizes sequentially; `ocaml-infer-let-rec-mut` pre-binds
all names with fresh tvs, infers each rhs against the joint env,
unifies, generalizes, then infers body. Mutual recursion works:
`let rec even n = ... and odd n = ... in even : Int -> Bool`.
- 2026-05-08 Phase 6 — Option/Result/Bytes extensions (+9 tests, 439
total). Option: join, to_result, some, none. Result: value, iter,
fold. Bytes: length, get, of_string, to_string, concat, sub (thin