ocaml: phase 5 parse ctor arg types in user type-defs (+3 tests, 409 total)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 36s

ocaml-hm-parse-type-src recognises primitive type names (int/bool/
string/float/unit), tyvars 'a, and simple parametric T list / T option.
Replaces the previous int-by-default placeholder in
ocaml-hm-register-type-def!.

So 'type tag = TStr of string | TInt of int' correctly registers
TStr : string -> tag and TInt : int -> tag. Pattern-match on tag
gives proper field types in the body. Multi-arg / function types
still fall back to a fresh tv.
This commit is contained in:
2026-05-08 15:43:16 +00:00
parent d61ee088c5
commit 4bca2cacff
3 changed files with 58 additions and 12 deletions

View File

@@ -236,8 +236,10 @@ SX CEK evaluator (both JS and OCaml hosts)
`ocaml-hm-register-type-def!` registers user types from `:type-def`.
`ocaml-type-of-program` threads decls through the env, registering
types and binding `let` schemes. `:con NAME` / `:pcon NAME …`
instantiate from the registry. _(Caveat: ctor arg types currently
default to `int` — proper type parsing pending.)_
instantiate from the registry. Ctor arg types parsed via
`ocaml-hm-parse-type-src` — handles primitives (`int`/`bool`/
`string`/`float`/`unit`), tyvars `'a`, simple parametric `T list`/
`T option`. Multi-arg/complex types fall back to a fresh tv.
- [~] Function types `T1 -> T2` work; tuples (`'a * 'b`) and lists
(`'a list`) supported. Records pending.
- [ ] Type signatures: `val f : int -> int` — verify against inferred type.
@@ -377,6 +379,12 @@ the "mother tongue" closure: OCaml → SX → OCaml. This means:
_Newest first._
- 2026-05-08 Phase 5 — parse simple type sources in user type-defs
(+3 tests, 409 total). `ocaml-hm-parse-type-src` recognises
primitive type names, tyvars `'a`, and `T list`/`T option`-style
parametric types. Replaces the old "default to Int" placeholder so
`type t = TStr of string` correctly registers `TStr : string -> t`.
Multi-arg / function types still fall back to a fresh tv.
- 2026-05-08 Phase 6 — String extensions: ends_with/contains/trim/
split_on_char/replace_all/index_of (+6 tests, 406 total). Wraps host
primitives via `_string_*` builtins.