Fork me on GitHub
#clojure-spec
<
2017-04-10
>
srihari07:04:16

Is it possible to dynamically (at runtime) define a spec in clojurescript?

rovanion11:04:07

The macro clojure.spec/keys and clojure.spec/keys* expects a seq of keys as the value of its named arguments :req and :opt. I want to use the same list of keys for two different specs, one using keys and one using keys*. But the macros get passed the quoted symbol for the variable and not the value of it. Is it possible to unpack the value pointed to by a symbol at read time like the common lisp #. syntax?

frank14:04:29

I think that depending on how the macro was implemented, you may be able to

donaldball15:04:07

(eval `(s/def ::record (s/keys :req ~ks)))
is what I’ve been using when generating specs from data

tjtolton20:04:03

I'm sorry, I'm having trouble finding this in the docs (which leads me to believe core.spec has some kind of strong opinion on this) -- is there a canonical way of saying "a predicate that matches anything". essentially a predicate (fn [thing] true)

tjtolton20:04:23

looking for, essentially, (s/.)

tjtolton20:04:27

is that a thing?

tjtolton20:04:40

are you sure you're not thinking of prismatic?

schmee20:04:56

it is new in clojure 1.9

tjtolton20:04:27

ohh, you mean its like a clojure.core/any? ?

tjtolton20:04:39

how about that

stathissideris22:04:13

are there any efforts for a spec-based condp-like macro?

stathissideris22:04:29

something that would be a more general core.match