From 4981e9a32f4a2f6301e1d6ecf5ce31632efeb60e Mon Sep 17 00:00:00 2001 From: giles Date: Thu, 16 Apr 2026 15:28:29 +0000 Subject: [PATCH] HS runtime: add Set/Map coercions to hs-coerce Co-Authored-By: Claude Opus 4.6 (1M context) --- lib/hyperscript/runtime.sx | 15 +++++++++++++++ shared/static/wasm/sx/hs-runtime.sx | 15 +++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/lib/hyperscript/runtime.sx b/lib/hyperscript/runtime.sx index b913f913..5739bc08 100644 --- a/lib/hyperscript/runtime.sx +++ b/lib/hyperscript/runtime.sx @@ -355,6 +355,21 @@ (list) value) value)) + ((= type-name "Set") + (if + (list? value) + (reduce + (fn + (acc x) + (if (some (fn (a) (= a x)) acc) acc (append acc (list x)))) + (list) + value) + value)) + ((= type-name "Map") + (if + (dict? value) + (map (fn (k) (list k (get value k))) (keys value)) + value)) (true value)))) (define diff --git a/shared/static/wasm/sx/hs-runtime.sx b/shared/static/wasm/sx/hs-runtime.sx index b913f913..5739bc08 100644 --- a/shared/static/wasm/sx/hs-runtime.sx +++ b/shared/static/wasm/sx/hs-runtime.sx @@ -355,6 +355,21 @@ (list) value) value)) + ((= type-name "Set") + (if + (list? value) + (reduce + (fn + (acc x) + (if (some (fn (a) (= a x)) acc) acc (append acc (list x)))) + (list) + value) + value)) + ((= type-name "Map") + (if + (dict? value) + (map (fn (k) (list k (get value k))) (keys value)) + value)) (true value)))) (define