haskell: Phase 11 — Data.Map transforming (foldlWithKey/foldrWithKey/mapWithKey/filterWithKey)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 1m20s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 1m20s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -186,7 +186,7 @@ No OCaml changes are needed. The view type is fully representable as an SX dict.
|
||||
`member`, `size`, `null`.
|
||||
- [x] Bulk operations: `fromList`, `toList`, `toAscList`, `keys`, `elems`.
|
||||
- [x] Combining: `unionWith`, `intersectionWith`, `difference`.
|
||||
- [ ] Transforming: `foldlWithKey`, `foldrWithKey`, `mapWithKey`, `filterWithKey`.
|
||||
- [x] Transforming: `foldlWithKey`, `foldrWithKey`, `mapWithKey`, `filterWithKey`.
|
||||
- [ ] Updating: `adjust`, `insertWith`, `insertWithKey`, `alter`.
|
||||
- [ ] Module wiring: `import Data.Map` and `import qualified Data.Map as Map`
|
||||
resolve to the `map.sx` namespace dict in the eval import handler.
|
||||
@@ -304,6 +304,16 @@ No OCaml changes are needed. The view type is fully representable as an SX dict.
|
||||
|
||||
_Newest first._
|
||||
|
||||
**2026-05-07** — Phase 11 transforming (foldlWithKey/foldrWithKey/mapWithKey/filterWithKey):
|
||||
- Folds traverse in-order. `foldlWithKey f acc m` walks left → key/val → right
|
||||
threading the accumulator, so left-folding `(\acc k v -> acc ++ k ++ v)` over
|
||||
a 3-key map yields `"1a2b3c"`. `foldrWithKey` runs right → key/val → left so
|
||||
the cons-style accumulator `(\k v acc -> k ++ v ++ acc)` produces the same
|
||||
string.
|
||||
- `mapWithKey` rebuilds the tree node-by-node (no rebalancing needed — keys
|
||||
unchanged so the existing structure stays valid). `filterWithKey` is a
|
||||
`foldrWithKey` that re-inserts kept entries; rebalances via insert.
|
||||
|
||||
**2026-05-07** — Phase 11 combining (unionWith/intersectionWith/difference):
|
||||
- All three implemented via `reduce` over the smaller map's `to-asc-list`,
|
||||
inserting / skipping into the result. Verified:
|
||||
|
||||
Reference in New Issue
Block a user