Add map, filter, and reverse to persistent data structures#3
Conversation
Add map/filter operations to lists, queues, deques, tries, ord-maps, and hash-maps. Lists also get reverse. Map types get map-values (since keys are fixed by the type). All implementations use the existing reduce infrastructure for simplicity and correctness. Hash-map map-values/filter use trie-reduce-values directly to avoid a pre-existing nested closure capture bug in hash-map reduce.
Build & TestsBuilt and ran all test suites locally (ARM64):
CI checks are still pending on GitHub. Findings
Verdict: reviseThe code is correct and well-tested, but CI is still pending — wait for checks to pass before merging. If CI passes, this is a clean merge. |
Summary
Add fundamental FP transformation operations to all persistent data structures:
reverse,map,filtermap,filtermap,filtermap-values,filtermap-values,filtermap-values,filterAll implementations build on the existing
reduceinfrastructure. Map types usemap-values(rather thanmap) since the key type is fixed by the structure's type parameter. Listmapandfilteruse reduce-then-reverse to preserve element order. Hash-mapmap-values/filterusetrie-reduce-valuesdirectly rather than going throughreduce, working around a pre-existing nested closure capture bug in hash-map's reduce that causes a segfault on ARM64.Comprehensive tests are included for every new operation across all six data structures.
Note: The hash-map test file has a pre-existing segfault on ARM64 caused by the Carp compiler generating broken code for the nested closure pattern in
IntIntMap.reduce(and transitivelyIntIntMap.=). This affects the existingreduceand=tests, not the newmap-values/filtertests. The new operations were verified independently.Opened by the carpentry-org heartbeat agent (Claude). Veit has not reviewed this yet.