This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-06-08
Channels
- # atlanta-clojurians (1)
- # beginners (116)
- # cider (70)
- # cljs-dev (11)
- # cljsrn (2)
- # clojure (218)
- # clojure-italy (7)
- # clojure-nl (14)
- # clojure-nlp (11)
- # clojure-spec (8)
- # clojure-uk (113)
- # clojurescript (86)
- # core-async (14)
- # cursive (24)
- # datomic (64)
- # duct (1)
- # emacs (3)
- # fulcro (20)
- # graphql (10)
- # jobs-rus (1)
- # london-clojurians (1)
- # luminus (1)
- # nyc (1)
- # off-topic (24)
- # onyx (1)
- # parinfer (1)
- # pedestal (14)
- # portkey (11)
- # re-frame (36)
- # reagent (9)
- # reitit (5)
- # ring (1)
- # shadow-cljs (197)
- # spacemacs (21)
- # specter (22)
- # sql (15)
- # tools-deps (5)
Is there a way to find out from what namespace/file a spec has been defined?
I'd be very interested in hearing an answer to this too!
Here's a spec puzzle for someone. I'm trying to get a spec that defines something like this:
([-7806 "rBQUP"] :_T-7/G0X)
I thought I would need to nest calls to s/cat
to do it, but those seem to flatten or something:
> (gen/generate (s/gen (s/cat :int int? :str string?)))
(-61568 "66420tRep6jHRW6q07x647hV6qE6q")
> (gen/generate (s/gen (s/cat :pair (s/cat :int int? :str string?) :keyword keyword?)))
(-7806 "rBQUP" :_T-7/G0X)
How do I get a collection of two items, where the first is a collection of one int and one string, and the second is a keyword?like hiredman said below, this should work: (gen/generate (s/gen (s/cat :pair (s/spec (s/cat :int int? :str string?)) :keyword keyword?)))
just to prevent the "flattening" of the nested regex specs
late to the party, s/tuple
isn't a regex spec so you can nest it as you like:
(s/valid? (s/tuple (s/tuple int? int?) keyword?) [[1 2] :a])
nested regex specs sort of collapse into a single regex spec (nested cats become subsequences within the outer sequence) so you have to insert something to tell spec where to stop collapsing them, and I think it is wrapping with s/spec, but it has been a while
I'd be very interested in hearing an answer to this too!