This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-01-25
Channels
- # announcements (4)
- # babashka (58)
- # beginners (21)
- # calva (42)
- # clj-kondo (15)
- # cljdoc (16)
- # cljs-dev (11)
- # clojure (57)
- # clojure-denmark (1)
- # clojure-europe (24)
- # clojure-france (4)
- # clojure-nl (1)
- # clojure-norway (16)
- # clojure-spec (6)
- # clojure-uk (2)
- # clojurescript (19)
- # clr (4)
- # conjure (1)
- # core-logic (3)
- # cursive (5)
- # data-science (2)
- # datascript (6)
- # datomic (3)
- # emacs (4)
- # events (3)
- # fulcro (17)
- # gratitude (2)
- # hyperfiddle (4)
- # introduce-yourself (3)
- # jobs-discuss (2)
- # lsp (27)
- # malli (22)
- # pathom (73)
- # portal (21)
- # re-frame (5)
- # releases (1)
- # vim (8)
- # xtdb (28)
Hi, I would like to extract a spec from a function spec (`s/fdef`). I realized since the spec is speccing an arglist this might be a bit challenging. Right now I wanted to extract the 2nd arg spec always. Context: https://github.com/WorksHub/leona/issues/4
(defn droid-resolver [ctx query value])
(s/def ::int int?)
(s/def ::string string?)
(s/def ::any any?)
(s/fdef droid-resolver
:args (s/cat :a ::int :b ::string :c ::any)
:ret ::int)
(let [[_ _ _ _ b-spec]
(s/form (:args (s/get-spec #'droid-resolver)))]
b-spec)
:leona.core-test/string
this would not fly would it? It would fail if someone defines a spec differently than cat
?
Yes, it would fail if that spec changed
There’s not really a way to get the spec of a specific arg like that