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
anthony-galea 2020-09-15T09:28:21.126400Z

@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

tvalerio 2020-09-15T12:01:04.126500Z

Ok, I understood. Thanks @anthony-galea! =D

kenny 2020-09-15T17:35:25.128300Z

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}

seancorfield 2020-09-15T17:59:01.128600Z

(the API URL was incorrect)

alexmiller 2020-09-15T18:05:04.129400Z

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

alexmiller 2020-09-15T18:07:42.129900Z

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}

seancorfield 2020-09-15T18:37:45.130300Z

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

kenny 2020-09-15T20:25:19.130600Z

Great, that works perfect. Thank you!