ocaml: phase 4 functors + module aliases (+5 tests, 225 total)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 53s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 53s
Parser: module F (M) (N) ... = struct DECLS end -> (:functor-def NAME PARAMS DECLS). module N = expr (non-struct) -> (:module-alias NAME BODY-SRC). Functor params accept (P) or (P : Sig) — signatures parsed-and-skipped via skip-optional-sig. Eval: ocaml-make-functor builds curried host-SX closures from module dicts to a module dict. ocaml-resolve-module-path extended for :app so F(A), F(A)(B), and Outer.Inner all resolve to dicts. Phase 4 LOC ~290 cumulative (still well under 2000).
This commit is contained in:
@@ -181,11 +181,13 @@ SX CEK evaluator (both JS and OCaml hosts)
|
||||
|
||||
- [x] `module M = struct let x = 1 let f y = x + y end` → SX dict
|
||||
`{"x" 1 "f" <fn>}`.
|
||||
- [ ] `module type S = sig val x : int val f : int -> int end` → interface record
|
||||
(runtime stub; typed checking in Phase 5).
|
||||
- [ ] `module M : S = struct ... end` — coercive sealing (runtime: pass-through).
|
||||
- [ ] `functor (M : S) -> struct ... end` → SX `(fn (M) ...)`.
|
||||
- [ ] `module F = Functor(Base)` — functor application.
|
||||
- [~] `module type S = sig val x : int val f : int -> int end` — signature
|
||||
annotations are parsed-and-skipped (`skip-optional-sig`); typed
|
||||
checking deferred to Phase 5.
|
||||
- [x] `module M : S = struct ... end` — coercive sealing (signature ignored).
|
||||
- [x] `functor (M : S) -> struct ... end` via shorthand `module F (M) = …`.
|
||||
- [x] `module F = Functor(Base)` — functor application; multi-param via
|
||||
`module P = F(A)(B)`.
|
||||
- [x] `open M` — merge M's dict into current env (via
|
||||
`ocaml-env-merge-dict`). Module path `M.Sub` resolves via
|
||||
`ocaml-resolve-module-path`.
|
||||
@@ -325,6 +327,16 @@ the "mother tongue" closure: OCaml → SX → OCaml. This means:
|
||||
|
||||
_Newest first._
|
||||
|
||||
- 2026-05-08 Phase 4 — functors + module aliases (+5 tests, 225 total).
|
||||
Parser: `module F (M) = struct DECLS end` → `(:functor-def NAME PARAMS
|
||||
DECLS)`. `module N = expr` (where expr isn't `struct`) → `(:module-alias
|
||||
NAME BODY-SRC)`. Functor params accept `(P)` or `(P : Sig)` (signatures
|
||||
parsed-and-skipped). Eval: `ocaml-make-functor` builds a curried
|
||||
host-SX closure that takes module dicts and returns a module dict;
|
||||
`ocaml-resolve-module-path` extended for `:app` so `F(A)`, `F(A)(B)`,
|
||||
`Outer.Inner` all resolve to dicts. Tested: 1-arg functor, 2-arg
|
||||
curried `Pair(One)(Two)`, module alias, submodule alias, identity
|
||||
functor with include. Phase 4 LOC ~290 (still well under 2000).
|
||||
- 2026-05-08 Phase 4 — `open M` / `include M` (+5 tests, 220 total).
|
||||
Parser: top-level `open Path` / `include Path` decls; path is `Ctor (.
|
||||
Ctor)*`. Eval resolves the path via `ocaml-resolve-module-path` (the
|
||||
|
||||
Reference in New Issue
Block a user