Fork me on GitHub
#clojure-spec
<
2019-07-24
>
y.khmelevskii06:07:41

Hi gents! Is there any way to use spec/keys definition for creating new spec as set of keys? For example I have spec:

(s/def ::schema
  (s/keys :req-un [::id
                   ::name
                   ::active?]
               :opt-un [::age]))
I want to create other spec based on ::schema
(s/def ::fields
  #{:id :name :active? :age})

danieroux12:07:50

How would I generate a random walk with clojure.spec.gen? Or, how would I generate a successive value based on the current value?

respatialized14:07:29

I think the easiest way would be to use spec.gen for starting values and then use iterate to do the actual random walks. you could use specs inside the fn you pass to iterate to constrain the return values.

respatialized14:07:29

I think the easiest way would be to use spec.gen for starting values and then use iterate to do the actual random walks. you could use specs inside the fn you pass to iterate to constrain the return values.

respatialized14:07:44

does anyone have any thoughts on making spec predicates usable through a java API? should I just use spec/conform to define the class methods I want to expose to the Java API?

Alex Miller (Clojure team)14:07:44

can you explain more what you're trying to do?

respatialized14:07:08

I'm using core.spec to define a series of data integrity/quality predicates that some data needs to conform to. I would like for those specs to be available as widely as possible, including for other consumers of the data who may be using Java instead of Clojure.