Fork me on GitHub
#clojure-spec
<
2021-01-23
>
ikitommi14:01:39

what is the use case or rationale for s/map-of not conforming the keys by default?

(s/conform 
  (s/map-of (s/or :s string? :b boolean?) 
            (s/or :s string? :b boolean?)) 
  {"k" "v"})
; => {"1" [:s "1"]}

(s/conform 
  (s/map-of (s/or :s string? :b boolean?) 
            (s/or :s string? :b boolean?) 
            :conform-keys true) 
  {"k" "v"})
; => {[:s "k"] [:s "v"]}

Alex Miller (Clojure team)14:01:21

Usually keys are things that are not changed by conforming (keywords, strings, longs, symbols) and there is cost to conforming things, so defaults to not doing it.

ikitommi14:01:12

ok, thanks.