This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-01-20
Channels
- # arachne (11)
- # aws (2)
- # beginners (33)
- # boot (167)
- # cider (71)
- # clara (2)
- # cljs-dev (28)
- # cljsrn (3)
- # clojars (1)
- # clojure (83)
- # clojure-austin (21)
- # clojure-dev (24)
- # clojure-russia (19)
- # clojure-spec (33)
- # clojure-uk (108)
- # clojurescript (114)
- # component (1)
- # core-async (1)
- # cursive (7)
- # datomic (13)
- # editors (1)
- # emacs (15)
- # hoplon (10)
- # lein-figwheel (4)
- # leiningen (3)
- # mount (2)
- # om (134)
- # om-next (4)
- # onyx (42)
- # pedestal (41)
- # quil (2)
- # re-frame (29)
- # reagent (4)
- # remote-jobs (6)
- # ring-swagger (5)
- # untangled (9)
just curious: why does s/keys check the map? predicate? seems like ILookup is the minimum requirement, or am i missing something?
I believe there's a JIRA issue open for that...
It has to iterate through the entries so ILookup is not sufficient
Makes sense. I forgot about how it handles present keys even if not specified as optional.
One solution would be to only provide that functionality if iterable or seqable. Not sure if that's a great idea though.
maybe this is a FAQ, but is there a way to automatically re-run clojure.spec/instrument after defining new functions or redefining already specced ones? I’d be fine if it would work in CIDER only.
Can I use it in "production"? Or call s/conform at beginning of function? https://clojure.org/guides/spec#_instrumentation
In production what I do is leverage :pre/:post + s/valid? in functions. and you can always turn it off with a compile time toggle. It works quite well
Hey, I have a kind of polymorphic map where some keys should be present depending on the value of one of the other keys, so it's like either {:x/type :t/foo :foo/val 32}
or {:x/type :t/bar :bar/baz "47"}
It seems like this is difficult to describe with spec since the map specs only look at keys, not values. Am I missing something?
Aha! Exactly what I was looking for. Thanks @potetm.
Posed a question in the general Clojure channel, but realised that I need to think about predicates that reference their environment a little more. This was the snippet that I was pondering:
user> (let [limit 100] (s/form (s/spec #(< % limit))))
(clojure.core/fn [%] (clojure.core/< % limit))
I just answered in #clojure
s/form is there for that purpose (with some known bugs)
thanks for the answer @alexmiller and sorry for posting on wrong channel 🙂
serialization with captured environments can get a bit tricky anyways.