This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-12-01
Channels
- # adventofcode (1)
- # bangalore-clj (1)
- # beginners (8)
- # boot (47)
- # cider (6)
- # cljsrn (3)
- # clojure (155)
- # clojure-brasil (2)
- # clojure-china (3)
- # clojure-conj (1)
- # clojure-hk (4)
- # clojure-korea (36)
- # clojure-russia (38)
- # clojure-spec (53)
- # clojure-taiwan (1)
- # clojure-uk (14)
- # clojurescript (70)
- # clojurex (9)
- # component (2)
- # cursive (20)
- # datascript (19)
- # datomic (39)
- # defnpodcast (1)
- # events (5)
- # figwheel (2)
- # hoplon (81)
- # incanter (2)
- # jobs (7)
- # juxt (3)
- # klipse (1)
- # leiningen (1)
- # luminus (15)
- # mount (1)
- # off-topic (21)
- # om (5)
- # om-next (2)
- # onyx (19)
- # pedestal (2)
- # proto-repl (1)
- # proton (5)
- # re-frame (19)
- # reagent (4)
- # rethinkdb (2)
- # ring-swagger (6)
- # rum (13)
- # specter (6)
- # untangled (4)
- # yada (1)
hello, do function specs and other specs end up in different parts of the registry?
for example, I have a call like that: (foo {::foo 1})
can I safely do (s/def ::foo integer?)
and (s/fdef ::foo …)
No, those will collide (and the fdef will not be used)
Def puts keyword keys in the registry and fdef puts symbol keys in the registry
oh so my example should really be (s/fdef foo …)
instead, in which case no collision
correct?
I have another one: is there a shorter form for (let [{:keys [::stats/foo ::stats/bar]} {::stats/foo 2}] foo)
@alexmiller btw, I enjoyed your interview for the defn podcast, quite intriguing (all the stuff about secret future plans for clojure)
thanks
@re collision - right
Re destructuring, yes
Do ::stats/keys [foo bar]
Live stream from AustinClojure meeting by Stu on spec https://m.youtube.com/watch?v=dQcNAscSTSw
i’m totally blown away by how i have a namespace with > 100 defns, only 4 fundamental ones of which have specs, and they help me catch tons of errors - super nice
the return value of instrument reminds me of just how little spec you actually need to get some value from it
the official spec guide is very well written, had no issues consuming it to once for deep comprehension and also been able to quickly scan it for answers
Hey, I experienced an issue in clojure.spec
where :fn
key in fdef
is ignored (clojure 1.9-alpha14)
Here is MVP demonstrating the problem.
(defn add [x y]
#_(+ x y)
2)
(s/fdef add
:args (s/cat :x number? :y number?)
:ret number?
:fn #(= (+ (-> % :args :x)
(-> % :args :y)) (:ret %)))
(clojure.spec.test/instrument `add)
If I call (add 1 nil)
I got spec error, but when I call (add 1 2)
spec says everything is ok, despite the fact add
always returns 2
Can anybody help me?@mishadoff AFAICT instrument
only checks :args (and apparently not :ret or :fn)
this is surprising to me too but that’s how it’s documented:
from the instrument
docstring
@mishadoff @joost-diepenmaat - this has got to be FAQ #1 on clojure-spec 🙂 clojure.spec.test/instrument
will only check :args
(it’s meant to throw errors if you are using the function incorrectly); clojure.spec.test/check
will run generative tests and check that the function is implemented correctly.
Blogged about Schema & Clojure Spec for Web Developers. http://www.metosin.fi/blog/schema-spec-web-devs/ hopefully everyone's spec lib got mentioned.
Well, I decided to finally give spec a whirl, moved to 1.9.0-alpha14, and promptly discovered that I can’t get a REPL running because one of my dependencies has a non-conforming defn
. 😒 Anything I can do here short of replacing / removing the (slightly busted) library?
Most offending libs have newer versions that fix these problems
@alexmiller: I’m aware—you actually patched the library in question 😄 (Aleph). But a new release hasn’t been cut yet.
You could s/fdef a dummy spec over the defn spec
But might be tricky to get that loaded at the right time
@alexmiller: Gotcha. But I’d basically be overriding it globally, right?
Ah, my mistake—there is an alpha release of Aleph with a conforming defn
. (Didn’t release lein ancient
wouldn’t show that.)
i’ve got some metadata on some objects that i’d like to document better than with a comment
Still a possibility
There is not an obvious place to hang it atm, but there are some options
I don't mean syntax, I mean where to remember it
Could be easily added to s/def
You don't have to provide it as metadata (or store it as metadata)