haskell: Phase 11 — Data.Map core operations (singleton/insert/lookup/delete/member/null)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 1m45s

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-07 09:02:47 +00:00
parent a29bb6feca
commit 180b9009bf
2 changed files with 152 additions and 1 deletions

View File

@@ -182,7 +182,7 @@ No OCaml changes are needed. The view type is fully representable as an SX dict.
- [x] Implement a weight-balanced BST in pure SX in `lib/haskell/map.sx`.
Internal node representation: `("Map-Node" key val left right size)`.
Leaf: `("Map-Empty")`.
- [ ] Core operations: `empty`, `singleton`, `insert`, `lookup`, `delete`,
- [x] Core operations: `empty`, `singleton`, `insert`, `lookup`, `delete`,
`member`, `size`, `null`.
- [ ] Bulk operations: `fromList`, `toList`, `toAscList`, `keys`, `elems`.
- [ ] Combining: `unionWith`, `intersectionWith`, `difference`.
@@ -304,6 +304,15 @@ No OCaml changes are needed. The view type is fully representable as an SX dict.
_Newest first._
**2026-05-07** — Phase 11 core operations on `Data.Map` BST:
- Added `hk-map-singleton`, `hk-map-insert`, `hk-map-lookup`, `hk-map-delete`,
`hk-map-member`, `hk-map-null`. Insert recurses with `hk-map-balance` to
maintain weight invariants. Lookup returns `("Just" v)` / `("Nothing")` —
matches Haskell ADT layout. Delete uses a `hk-map-glue` helper that picks
the larger subtree and pulls its extreme element to the root, preserving
balance without imperative state. Spot-checked: insert+lookup hit/miss,
member, delete root with successor pulled from right.
**2026-05-07** — Phase 11 BST skeleton in `lib/haskell/map.sx`:
- Adams-style weight-balanced tree: node = `("Map-Node" k v l r size)`,
empty = `("Map-Empty")`. delta=3 / gamma=2 ratios. Implemented constructors