This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-02-09
Channels
- # beginners (205)
- # boot (6)
- # cider (22)
- # cljs-dev (41)
- # cljsrn (4)
- # clojure (97)
- # clojure-dev (61)
- # clojure-greece (40)
- # clojure-italy (8)
- # clojure-russia (16)
- # clojure-spec (18)
- # clojure-uk (34)
- # clojurescript (14)
- # community-development (1)
- # cursive (45)
- # datomic (39)
- # fulcro (66)
- # jobs (2)
- # lein-figwheel (1)
- # lumo (9)
- # off-topic (8)
- # parinfer (98)
- # portkey (8)
- # re-frame (81)
- # reagent (54)
- # remote-jobs (17)
- # ring (2)
- # shadow-cljs (217)
- # spacemacs (32)
- # sql (24)
- # test-check (6)
- # unrepl (73)
- # yada (12)
@gfredericks sorry the delay, I'm not sure I can use recursive-gen on this case
but I was able to make it work
this how it ended up:
(s/def ::query
(s/coll-of ::query-expr :kind vector?
:gen #(let [g (s/gen (s/coll-of ::query-expr :kind vector? :max-count 5))]
(gen/->Generator
(fn [rdn size]
(if (> *query-gen-max-depth* 0)
(binding [*query-gen-max-depth* (dec *query-gen-max-depth*)]
(gen/call-gen g rdn size))
(gen/call-gen (gen/return []) rdn size)))))))
this limits the depth of the generator by using a dynamic var, was the best solution I could find
yeah, I think it's technically possible with recursive-gen but maybe not easy would definitely be better for spec to handle it without error