Fork me on GitHub
#clojure-spec
<
2022-08-22
>
lilactown18:08:37

is there a reason that there's no concrete Spec type/class? I have a desire to extend a library I'm writing to dispatch on whether a value is a reified spec value, and I can't easily do that without taking a dependency directly on clojure.spec.alpha

lilactown18:08:08

i.e. the only way I can tell whether I've been passed a spec is by using s/spec?

Alex Miller (Clojure team)18:08:34

You could dynamically load and resolve that function

lilactown18:08:41

that doesn't work in CLJS

lilactown18:08:57

in various places in clojure.spec.alpha an object is created via (reify Spec ,,,) and returned, which is what I want to extend the behavior of

lilactown18:08:19

I don't care about the name, just wishing there was a concrete type I could extend

Alex Miller (Clojure team)18:08:44

sets are also specs, and functions. there is not "one type" to check for

Alex Miller (Clojure team)18:08:58

the behavior is defined via the protocol. things like with-gen are a good example of extending by wrapping. but maybe there is some better way to do what you need, not sure