This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-10-01
Channels
- # aws (37)
- # babashka (7)
- # babashka-sci-dev (2)
- # beginners (75)
- # biff (7)
- # calva (85)
- # cider (9)
- # clj-kondo (26)
- # clj-yaml (1)
- # clojure (45)
- # clojure-europe (4)
- # clojure-norway (1)
- # clojure-spec (3)
- # clojure-uk (2)
- # clojurescript (3)
- # core-typed (2)
- # cursive (12)
- # fulcro (3)
- # humbleui (5)
- # jobs (8)
- # malli (1)
- # meander (3)
- # membrane (1)
- # portal (50)
- # squint (15)
- # vim (1)
Does anybody know of a lib that allows me to inline fn specs in the fn’s metadata? Looking for something like:
(defn myfn
{:spec (...)}
...)
… which would be equivalent to:
(defn myfn ...)
(s/fdef myfn ...)
I don't know of a library that does this specifically, but I think it should be doable with a macro. Perhaps something like this:
;; idea: create a macro defn+spec
(defn+spec myfn
{:spec (,,,)}
[]
,,,)
;; so that it expands to
(do
(defn myfn
{:spec (,,,)}
[]
,,,)
(s/fdef myfn (:spec (meta #'myfn))))
There's https://github.com/danielcompton/defn-spec which has links to some other libs too in the README
👍 1