ocaml: phase 6 Map.Make / Set.Make functors (+4 tests, 418 total)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 45s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 45s
Both written in OCaml inside lib/ocaml/runtime.sx:
module Map = struct module Make (Ord) = struct
let empty = []
let add k v m = ... (* sorted insert via Ord.compare *)
let find_opt / find / mem / remove / bindings / cardinal
end end
module Set = struct module Make (Ord) = struct
let empty = []
let mem / add / remove / elements / cardinal
end end
Sorted association list / sorted list backing — linear ops but
correct. Strong substrate-validation: Map.Make is a non-trivial
functor implemented entirely on top of the OCaml-on-SX evaluator.
This commit is contained in:
@@ -286,8 +286,11 @@ SX CEK evaluator (both JS and OCaml hosts)
|
||||
- [ ] `Int`/`Float`: arithmetic, `to_string`, `of_string_opt`, `min_int`, `max_int`.
|
||||
- [ ] `Hashtbl`: `create`, `add`, `replace`, `find`, `find_opt`, `remove`, `mem`,
|
||||
`iter`, `fold`, `length` — backed by SX mutable dict.
|
||||
- [ ] `Map.Make` functor — balanced BST backed by SX sorted dict.
|
||||
- [ ] `Set.Make` functor.
|
||||
- [x] `Map.Make` functor — sorted association list backed
|
||||
(insert/find/remove/mem/cardinal/bindings); not a balanced tree
|
||||
but linear with parametric `Ord` ordering.
|
||||
- [x] `Set.Make` functor — sorted list backed
|
||||
(add/mem/remove/elements/cardinal).
|
||||
- [ ] `Printf`: `sprintf`, `printf`, `eprintf` — format strings via `(format ...)`.
|
||||
- [ ] `Sys`: `argv`, `getenv_opt`, `getcwd` — via `perform` IO.
|
||||
- [ ] Scoreboard runner: `lib/ocaml/conformance.sh` + `scoreboard.json`.
|
||||
@@ -383,6 +386,14 @@ the "mother tongue" closure: OCaml → SX → OCaml. This means:
|
||||
|
||||
_Newest first._
|
||||
|
||||
- 2026-05-08 Phase 6 — `Map.Make` / `Set.Make` functors written in
|
||||
OCaml (+4 tests, 418 total). Sorted association list / sorted list
|
||||
backed (linear ops, but correct). Both take an `Ord` module supplying
|
||||
`compare`. Tested: `module IntMap = Map.Make(IntOrd) ;; IntMap.find
|
||||
…` and `IntSet.elements (IntSet.add 3 (IntSet.add 1 …))` returning
|
||||
`[1; 2; 3]`. Strong substrate-validation for the functor system —
|
||||
Map.Make is a non-trivial functor implemented entirely on top of the
|
||||
OCaml-on-SX evaluator.
|
||||
- 2026-05-08 Phase 6 — `Sys` module constants (+5 tests, 414 total).
|
||||
os_type, word_size, max_array_length, max_string_length,
|
||||
executable_name, big_endian, unix, win32, cygwin. Constants-only
|
||||
|
||||
Reference in New Issue
Block a user