Fork me on GitHub
Alex Miller (Clojure team)13:09:27

The validation benchmark has been updated with alpha12 showing the spec improvements:


Pretty massive improvements

Alex Miller (Clojure team)14:09:32

yes, should help a lot with runtime use cases


alexmiller: that's great. Means I'll use it to conform stuff in my sparkling spark jobs. :-D Thx!

Alex Miller (Clojure team)15:09:45

generally, it’s faster than schema, so if schema was fast enough for you, it should be sufficient


alexmiller: that was my alternative so I'm very happy. :-D


I'm going to have to study the commit(s) that are responsible for that massive speed up -- very curious about how that was achieved! 😸

Alex Miller (Clojure team)15:09:11

lot of changes. one change of possible importance is that a spec using another registered spec will “compile” in that definition, so changes to the upstream spec (during dev) now require the downstream spec to be reloaded

Alex Miller (Clojure team)15:09:20

so it’s a little less dynamic than prior

Alex Miller (Clojure team)15:09:37

this does not affect recursive specs as delays are used


> (s/conform (s/coll-of int? :type set?) #{0 1})
#{0 1}
> (s/conform (s/coll-of int? :type set?) [0 1])
[0 1]
(s/conform (s/coll-of int? :type set?) [0 "e"])


not sure why I'm not getting invalid on the 2nd one


ah, I think I need :into


> (s/conform (s/coll-of int? :into #{}) [0 1])
#{0 1}


seems to work


I'm hitting odd behavior with clojure.spec and I'm not sure it's me or a bug in clojure.spec. Here's the example: What I would expect is no surrounding [] around [:nested ...] in the second case. It seems that ::link-value spec is clashing with the ::query spec. If I change ::link-value to e.g. (s/tuple symbol? keyword?) I don't get the extract []. The odd thing is that despite the "clash", [:link ...] never appears in the output... any ideas?

Alex Miller (Clojure team)16:09:39

if only you had the spec specs, it would tell you that :)

Alex Miller (Clojure team)16:09:24

@jannis so the one you’re asking about is

(s/conform ::query '[a b [c d]])
;;=> [[:single [:simple a]]
;;    [:nested {:parent [:simple b], :children [[:single [:simple c]]]}]]

Alex Miller (Clojure team)16:09:53

the outermost [ ] is from ::query

Alex Miller (Clojure team)16:09:10

the [ ] around :single and :nested are due to the s/alt tagging


@alexmiller thx. Mostly just flailing around in the library trying to learn it (and getting dumb things wrong) 😉


@alexmiller The one I'm asking about is [[:single [:simple a]] [[:nested ...]]] - with the [[:nested ..]] instead of [:nested ..].


What's puzzling me there is that the other two examples don't have the extra [] around [:nested ...] - and that I can make it disappear in the second case if I change the :link-value spec that should have no impact here.


(This is Clojure 1.9.0-alpha11 by the way)

Alex Miller (Clojure team)16:09:20

oh, this reminds me of something

Alex Miller (Clojure team)16:09:39

that example in the comment also has something similar

Alex Miller (Clojure team)16:09:12

I’ve been looking at some regex conform results that seem off to me - although most of those relate to use of s/?


The output certainly looks similar 😉


In this case I think s/conform may not know which of [::query :single :link] and [::query :nested :children] to pick. It decides on :nested instead of :single but surrounds it with the extra [] for some reason.


Could that be what happens in case of ambiguity?

Alex Miller (Clojure team)16:09:37

I don’t think that’s what’s happening - I think it has to do with the guts of the regex derivatives and when it decides to create the nested context


You know the internals, I don't. 😉 Is there anything I can do to help investigate the problem (if it is one at all)?

Alex Miller (Clojure team)17:09:06

no, I’m looking at some of this stuff already

Alex Miller (Clojure team)17:09:23

if you wanted to boil it down to a simpler repro and file a jira, that would be helpful

Alex Miller (Clojure team)17:09:42

just to make sure that it does get addressed and not just “in my head” :)


how do I spec that a map should look like: {:db/id <something>}. I don't own the db namespace so am not sure how to spec for that.


@fenton you don't need to own a namespace to refer to it

Alex Miller (Clojure team)20:09:58

and then separately (s/def :db/id <something>)

Alex Miller (Clojure team)20:09:40

which could come from a lib or could be something you build


(s/def :db/id (s/tuple #{:pc.api/name} string?)) (s/def ::kwm (s/keys req [:db/id]))


{:db/id [:pc.api/name "JCZ4vAlwyUl6r37PeVJ"]} is what i'm going for


repl> (gen/generate (s/gen :pc.api/kwm)) {}


pcbe.http> (s/valid? :pc.api/kwm {:db/id [:pc.api/name "orange"]}) true