clojure-spec

ray 2024-10-10T08:02:02.964409Z

is there a way to have qualified keys returned in the usual way rather than reader tags (if that's the correct term). I'm a bit stuck cos even when I add a conformer which explicitly re-writes hard-coded values, it still returns the keys in this format

(->> (s/conform ::bindings '[{:a/keys [x]} {:a/x 1}])
     (s/unform ::bindings))
=> (#:a{:keys [x]} #:a{:x 1})

lassemaatta 2024-10-10T08:04:19.825939Z

perhaps https://clojuredocs.org/clojure.core/*print-namespace-maps* might help somehow?

ray 2024-10-10T08:08:44.977559Z

til

ray 2024-10-10T08:08:59.038299Z

I'll give it a try

ray 2024-10-10T08:18:30.743089Z

Doesn't seem to make a difference ... this is in the default clj REPL

(in-ns 'clojure.core.specs.alpha)
#object[clojure.lang.Namespace 0x3d36dff4 "clojure.core.specs.alpha"]

clojure.core.specs.alpha=> 

(s/conform ::bindings '[{:a/keys [x]} {:a/x 1}])
[{:form [:map-destructure #:a{:keys [x]}], :init-expr #:a{:x 1}}]

(binding [*print-namespace-maps* false]
  (s/conform ::bindings '[{:a/keys [x]} {:a/x 1}]))
[{:form [:map-destructure #:a{:keys [x]}], :init-expr #:a{:x 1}}]

clojure.core.specs.alpha=> 

lassemaatta 2024-10-10T08:41:21.343229Z

ah yes, the binding only applies to the body within, but when the expression is returned and the repl prints it we're already outside the binding. Check the note on the clojuredocs link above wrt. print-method

ray 2024-10-10T08:51:26.864699Z

Yeah, fair point, though I was hoping to avoid that 🙈

ray 2024-10-10T09:57:57.726209Z

ha - that does the job. Thanks @lasse.olavi.maatta 🙏🏼

👍 1