Files
rose-ash/lib/haskell/set.sx
giles 208953667b
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 35s
haskell: Phase 12 — Data.Set skeleton (wraps Data.Map with unit values)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-07 11:37:39 +00:00

31 lines
1.0 KiB
Plaintext

;; set.sx — Phase 12 Data.Set: wraps Data.Map with unit values.
;;
;; A Set is a Map from key to (). All set operations delegate to the map
;; ops, ignoring the value side. Storage representation matches Data.Map:
;;
;; Empty → ("Map-Empty")
;; Node → ("Map-Node" key () left right size)
;;
;; Tradeoff: trivial maintenance burden, slight overhead per node from
;; the unused value slot. Faster path forward than re-implementing the
;; weight-balanced BST.
;;
;; Functions live in this file; the Haskell-level `import Data.Set` /
;; `import qualified Data.Set as Set` wiring (next Phase 12 box) binds
;; them under the chosen alias.
(define hk-set-unit (list "Tuple"))
(define hk-set-empty hk-map-empty)
(define hk-set-singleton (fn (k) (hk-map-singleton k hk-set-unit)))
(define hk-set-insert (fn (k s) (hk-map-insert k hk-set-unit s)))
(define hk-set-delete hk-map-delete)
(define hk-set-member hk-map-member)
(define hk-set-size hk-map-size)
(define hk-set-null hk-map-null)
(define hk-set-to-asc-list hk-map-keys)
(define hk-set-to-list hk-map-keys)