This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-12-14
Channels
- # adventofcode (14)
- # announcements (3)
- # babashka (18)
- # beginners (32)
- # calva (1)
- # clj-kondo (65)
- # cljs-dev (5)
- # cljsrn (3)
- # clojure (22)
- # clojure-spec (13)
- # clojure-uk (53)
- # clojured (3)
- # clojuredesign-podcast (50)
- # clojurescript (8)
- # core-async (32)
- # cursive (15)
- # data-science (1)
- # datomic (17)
- # fulcro (48)
- # hyperfiddle (1)
- # off-topic (5)
- # shadow-cljs (2)
- # testing (2)
Hey, I was wondering if there was a shorthand for creating fdefs
, For example I have:
(s/fdef new-person
:args (s/cat :name :person/name
:age :person/age)
:ret :app/person)
(defn new-person [name age]
{:person/name name
:person/age age})
Which works, but it’s quite a lot noise (seeing that the fdef
is larger than the function itself
I know I shouldn’t be comparing spec to type signatures, but that’s basically what I’m doing here. Something like this would be pretty useful for me:
(s/sig new-person [:person/name :person/age] :app/person)
(defn new-person [name age]
{:person/name name
:person/age age})
Thanks, these sort of do what I want. But they replace defn which I don’t like. I couldn’t find anything so I ended up writing a quick macro:
(defmacro defsig
[fname fargs fret]
`(clojure.spec.alpha/fdef ~fname
:args (clojure.spec.alpha/cat ~@(apply concat (map vector (map (comp keyword str) (range)) fargs)))
:ret ~fret))
Stay tuned for spec 2.... :)
Rich is working on the design for this right now and it’s starting to look pretty good
👏 32
8
I'd be interested to hear what your workflow (feedback loop?) is for developing the language. Are there any blogs about that?
I did a talk at Clojutre that talks about it some