Fork me on GitHub
#clojure-spec
<
2020-09-15
>
anthony-galea09:09:21

@tvalerio See the following under the Literals section at https://clojure.org/reference/reader > A keyword that begins with two colons is auto-resolved in the current namespace to a qualified keyword So when you use ::rates inside rates.clj it’s as if you’ve written :develop.rates/rates but when you do the same inside rates-test.clj you get develop.rates-test/rates and not :develop.rates/rates

tvalerio12:09:04

Ok, I understood. Thanks @U446AB17F! =D

kenny17:09:25

It seems the conformed result of the pred passed to s/coll-of is getting disregarded. Is this behavior of expected?

(s/conform
    (s/and (s/tuple #{"a"} boolean?)
           (s/conformer (fn [[_ v]] [:a v])))
    ["a" true])
=> [:a true]

(s/conform
  (s/coll-of
    (s/and (s/tuple #{"a"} boolean?)
           (s/conformer (fn [[_ v]] [:a v])))
    :kind map?)
  {"a" true})
=> {"a" true}

seancorfield17:09:01

(the API URL was incorrect)

Alex Miller (Clojure team)18:09:04

@kenny I think because you are using :kind map? you're into the map-specific conforming logic which (by default) does not conform keys

Alex Miller (Clojure team)18:09:42

You can use :conform-keys to change that default:

(s/conform
  (s/coll-of
    (s/and (s/tuple #{"a"} boolean?)
           (s/conformer (fn [[_ v]] [:a v])))
    :kind map?
    :conform-keys true)
  {"a" true})

{:a true}

seancorfield18:09:45

(that's a more useful URL, sorry for the noise)

kenny20:09:19

Great, that works perfect. Thank you!