This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-02-25
Channels
- # announcements (5)
- # beginners (74)
- # boot (5)
- # cider (57)
- # cljdoc (5)
- # cljs-dev (45)
- # clojure (37)
- # clojure-dev (6)
- # clojure-europe (4)
- # clojure-italy (17)
- # clojure-nl (11)
- # clojure-spec (48)
- # clojure-uk (96)
- # clojurescript (79)
- # cursive (17)
- # data-science (1)
- # datomic (27)
- # emacs (2)
- # fulcro (22)
- # immutant (1)
- # java (62)
- # juxt (4)
- # kaocha (4)
- # lein-figwheel (5)
- # leiningen (6)
- # midje (1)
- # mount (1)
- # music (3)
- # nrepl (6)
- # off-topic (49)
- # pathom (10)
- # pedestal (2)
- # re-frame (43)
- # reagent (2)
- # ring (2)
- # shadow-cljs (78)
- # spacemacs (6)
- # test-check (2)
- # tools-deps (4)
@eoliphant ^^^ this is a bit simplified, as you probably will not have issuers as keyword, but it can be expanded with mapping of issuer to number format.
Thanks @misha, @borkdude. One other bit of fun is that at the end of the day, the number of issuers/formats could be large and might end up in a db
Is it possible to turn clojure/core.specs
off during macroexpansion? So you can see the failing expansion?
:thumbsup:
thanks
I’m assuming there’s a reason this couldn’t also be a set!
able var? Not that restarting my REPL is that difficult! 🙂
well it's in a system property as stuff is potentially checked while you're loading before you have a chance to set it
it could probably also be a dynvar (although that would need to be checked on every macroexpansion, so probably some perf impacts)
(spec/fdef data->graph
:args ::data
:ret ::graph)
why this does not work? I mean it will take for ever to start..."not work" == ?
is data->graph a macro or a function?
if a function, it shouldn't do anything until you instrument
(spec/def ::graph (clojure.spec.alpha/def
:importer.datamodel/graph
(clojure.spec.alpha/coll-of
(clojure.spec.alpha/or
:collection
(clojure.spec.alpha/coll-of
(clojure.spec.alpha/keys
:req-un
[:importer.datamodel/label]
:opt-un
[:importer.datamodel/center
:importer.datamodel/edge_id
:importer.datamodel/global_id
:importer.datamodel/name
:importer.datamodel/source
:importer.datamodel/target
:importer.datamodel/typ]))
:simple
clojure.core/keyword?))))
(spec/def ::data (clojure.spec.alpha/def
:importer.datamodel/data
(clojure.spec.alpha/coll-of
(clojure.spec.alpha/or
:collection
(clojure.spec.alpha/coll-of
(clojure.spec.alpha/keys
:req
[:importer.datamodel/global-id]
:opt
[:importer.datamodel/center
:importer.datamodel/part-of
:importer.datamodel/type]
:opt-un
[:importer.datamodel/attributes
:importer.datamodel/datasource
:importer.datamodel/features
:importer.datamodel/ioi-slice
:importer.datamodel/name
:importer.datamodel/url]))
:simple
clojure.core/keyword?))))
(spec/fdef data->graph
:args ::data
:ret ::graph)
Hi here! I'm hoping someone can help me out with what is probably a basic question about clojure spec
(defn starts-with-any?
"Return truthy if s starts with any character in chrs; otherwise nil."
[s chrs]
(seq (filter (fn [c] (string/starts-with? s (str c))) chrs)))
(s/fdef starts-with-any?
:args (s/cat :s string? :chrs string?)
:ret (s/nilable (s/coll-of char?))
:fn (s/or :nil-case #(-> % nil?)
:non-nil-case
(s/and #(= (-> % :ret set first) (-> % :args :s first))
#(= 1 (-> % :ret set count))
(fn [x] (subset? (-> x :ret set) (-> x :args :chrs set))))))
#(-> % nil?)
== nil?
btw
{:clojure.spec.alpha/problems ({:path [:fn :nil-case], :pred (clojure.core/fn [%] (clojure.core/-> % clojure.core/nil?)), :val {:args {:s "", :chrs ""}, :ret nil}, :via [], :in []} {:path [:fn :non-nil-case], :pred (clojure.core/fn [%] (clojure.core/= 1 (clojure.core/-> % :ret clojure.core/set clojure.core/count))), :val {:args {:s "", :chrs ""}, :ret nil}, :via [], :in []}), :clojure.spec.alpha/spec #object[clojure.spec.alpha$or_spec_impl$reify__2046 0x3d686af1 "clojure.spec.alpha$or_spec_impl$reify__2046@3d686af1"], :clojure.spec.alpha/value {:args {:s "", :chrs ""}, :ret nil}, :clojure.spec.test.alpha/args ("" ""), :clojure.spec.test.alpha/val {:args {:s "", :chrs ""}, :ret nil}, :clojure.spec.alpha/failure :check-failed}
Is there a recommended/succinct way to reuse a string regex spec in keyword form? That is, I have a spec that uses a regex to define a string format (in this case, it's an ID format). In some places, that value is used as a keyword in a map. I could break out the specifics, but was wondering if there is an easy way to do something in the spirit of (s/def ::id-as-keyword (as-keyword ::id-spec))