Fork me on GitHub

Reading “Out of the Tarpit” (, and maybe I’ve just got Spec on my mind, but this looks pretty familiar:


The article’s description of "Functional Relational Programming” includes a section on “Essential Logic” that seems to correspond very well with Spec!

Alex Miller (Clojure team)09:07:51

I think it's no accident that Clojure+Datomic overlap pretty well with Out of the Tarpit

Alex Miller (Clojure team)13:07:48

s/and flows conformed values through the predicates and the s/+ conforms to a vector

Alex Miller (Clojure team)13:07:36

Rich has mentioned a split into s/and and s/and-> to have both choices


@alexmiller: Thanks! Yes it could probably be useful sometimes to not have it flow through the predicates but evaluate them separately.

Alex Miller (Clojure team)15:07:20

separately, the need to validate this specific case of a regex and vector? is common and one I’ve run into many times in spec’ing macros and there might be some addition specifically for this


Has there been any talk about allowing local registries to use with clojure spec functions rather than only using the global registry? Similar to (make-hierarchy) and derive.

Alex Miller (Clojure team)20:07:56

I haven't heard such talk :)


I’m trying to use multi-spec but it doesn’t seem to work with defmethod’s :default dispatch, is this a bug or intentional?


I don’t think multi-spec behaves exactly like that. I believe there is no default to be had.


That’s unfortunate. Is there a better way to handle the validation where a field in the map determines the type and you want to explicitly constrain some types but provide a default base?


Ex: modeling analytics events, the :type provides the type of event, for :search events :terms are required, for :page-view events :url is required but for all other events there are no other constraints on the map


It seems it only dispatches on key defined in s/multi-spec not on the this


hmmm but I just tried (s/def :foo/bad-entity (s/multi-spec entity :does-not-exist)) (gen/sample (s/gen :foo/bad-entity) 1) and the program goes into an infinite loop


wait! not infinite loop I just get ExceptionInfo Couldn't satisfy such-that predicate after 100 tries.


makes sense it either matches a spec or it does not. I am back to my original argument 😛


I think it’s unexpected behavior if multi-spec works w/ multimethods but then doesn’t support the default behavior of them


@pdlug: yah I had the same issue I want to dispatch on type but it has to be based on a key on your map 😞


I still don’t see anything else that supports my example use case


yeah, my problem is that I want to dispatch on something else than a namespaced key on the map. I want to dispatch on meta from the map. Not always you want to expose the “type” on the actual entity


makes sense

Alex Miller (Clojure team)21:07:12

@pdlug you might also see if s/merge helps you in combining base+specific s/keys


Yeah but you would be able to have a generic event spec for all the other types.