Hey Guys,
I am looking for help creating a particular function/macro, right now I've
no experience using macro's and I'm under the impression it might be the
right solution to my problem, that produces a spec output but a very
specific spec output. My goal here is to reduce the constant repeating of
the same spec over and over with only the tag portion being the part that
changes.
this is a little helper function I've been using to reduce repeating
(defn- tag [tag] (s/and keyword? #{tag}))
this is the core of what I need help with, this is currently what I have
and find it not to work, even in macro form but that's most likely down to
my poor knowledge of macro's.
(defn html-spec-creator [html-tag]
(s/def html-tag
(s/or
:map (st-ds/spec html-tag {:tag (tag html-tag)})
:vector (s/cat :tag (tag html-tag)))))
(html-spec-creator ::a)
the intended output of the above is to produce the following
(s/def ::a (s/or :map (st-ds/spec ::a {:tag (tag :a)}) :vector (s/cat :tag (tag
:a))))
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.