clojure-spec

About: http://clojure.org/about/spec Guide: http://clojure.org/guides/spec API: https://clojure.github.io/spec.alpha/clojure.spec.alpha-api.html
ikitommi 2021-01-23T14:02:39.001Z

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"]}

alexmiller 2021-01-23T14:14:21.002800Z

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.

ikitommi 2021-01-23T14:46:12.003100Z

ok, thanks.