This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-05-30
Channels
- # admin-announcements (4)
- # alda (49)
- # beginners (42)
- # boot (55)
- # cider (33)
- # cljs-dev (4)
- # cljsjs (3)
- # cljsrn (152)
- # clojure (92)
- # clojure-belgium (3)
- # clojure-brasil (18)
- # clojure-dusseldorf (32)
- # clojure-france (2)
- # clojure-greece (10)
- # clojure-japan (1)
- # clojure-mexico (1)
- # clojure-russia (50)
- # clojure-sg (1)
- # clojure-spain (1)
- # clojure-spec (12)
- # clojurescript (262)
- # core-async (2)
- # cursive (7)
- # datomic (79)
- # emacs (16)
- # euroclojure (2)
- # events (1)
- # hoplon (260)
- # jobs (2)
- # jobs-discuss (1)
- # keechma (7)
- # luminus (8)
- # mount (7)
- # off-topic (3)
- # om (101)
- # onyx (33)
- # re-frame (34)
- # reagent (10)
- # slack-help (4)
When s/spec
is used to create a new sequential context, I can’t find a way to capture the sequential thing itself.
For example:
(s/def ::ingredient (s/cat :quantity number? :unit keyword?))
(s/def ::recipe (s/cat :amount (s/spec ::ingredient) :description string?))
(s/conform ::recipe [[2.0 :teaspoon] "Cinnamon"])
=> {:amount {:quantity 2.0, :unit :teaspoon}, :description "Cinnamon"}
Here, there seems to be no way to capture the [2.0 :teaspoon]
vector object if I also want to match its contents.
@cfleming: you are matching its contents via the cat. If you want to receive the vector as the conformed value you could use coll-of to do a different kind of match or use a conformer to transform the matched result into any arbitrary structure
Probably the latter is what you want
is there a way to update a map spec? I’d like to say “this fn takes a foo map, and returns a foo map with an extra key added on”. It’d be nice to say (s/def bar (conj foo ::extra-key)), without specifying the keys of the second map explicitly
Question: why is the second argument (`retag`) necessary in a multi-spec
expression? In the guide, it is the same as the dispatch function, and I don't see any use case where providing a different function would be beneficial. And if it's the same, naming it again is redundant, as it can be retrieved via the public field dispatchFn
.
As an experiment, I’ve added an optional spec namespace to clojure.java.jdbc: https://github.com/clojure/java.jdbc/blob/master/src/main/clojure/clojure/java/jdbc/spec.clj — feedback welcome (the tests attempt to require that ns and instrument clojure.java.jdbc when running tests, so under 1.9.0 the specs are actually checked for all calls in the tests)