This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-11-01
Channels
- # announcements (7)
- # babashka (41)
- # beginners (117)
- # cider (3)
- # clj-kondo (145)
- # cljdoc (25)
- # cljs-dev (19)
- # clojure (197)
- # clojure-dev (14)
- # clojure-europe (4)
- # clojure-italy (3)
- # clojure-nl (2)
- # clojure-spec (11)
- # clojure-uk (21)
- # clojuredesign-podcast (5)
- # clojurescript (29)
- # code-reviews (4)
- # cursive (87)
- # data-science (11)
- # datomic (29)
- # duct (2)
- # emacs (10)
- # graalvm (1)
- # lumo (13)
- # malli (2)
- # nrepl (5)
- # off-topic (25)
- # onyx (1)
- # pathom (6)
- # reagent (20)
- # reitit (4)
- # rewrite-clj (7)
- # shadow-cljs (114)
- # spacemacs (16)
I'm trying to write a macro that among other things needs to generate new specs by wrapping or merging existing ones, and it doesn't work. I made the simple following example
(defmacro wrapspec
[base-name base-spec]
(let [n-name `(keyword (str ":wrapped-" '~base-name))
new-spec (s/coll-of base-spec)]
`(s/def ~n-name ~new-spec)))
I'm not sure why doesn't this work? I tried with a symbol instead of a keyword too, to no availdid you look at the expansion?
just as a general technique it's important to (pprint (macroexpand-1 '(wrapspec 'abc int?)))
or whatever to see if it's doing what you want
here s/coll-of is going to be a spec object, which is not what you want
new-spec `(s/coll-of ~base-spec)
probably closer but I'm just eyeballing this
Anyone aware of issues with clojure.spec.alpha/gen
in cljs (using shadow-cljs)? This snippet works well in clj repl:
(s/def ::foo string?)
(s/gen ::foo)
but fails in cljs with: Var clojure.test.check.generators/simple-type-printable does not exist, clojure.test.check.generators never required at eval (/js/compiled/cljs-runtime/cljs.spec.gen.alpha.js:1854:8)