This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-08-18
Channels
- # announcements (2)
- # beginners (95)
- # cider (2)
- # cljdoc (5)
- # cljs-dev (11)
- # cljsrn (2)
- # clojure (12)
- # clojure-spec (11)
- # clojure-uk (3)
- # clojurescript (27)
- # code-reviews (4)
- # cursive (9)
- # data-science (1)
- # datomic (1)
- # emacs (7)
- # fulcro (13)
- # graalvm (28)
- # graphql (6)
- # nrepl (6)
- # off-topic (13)
- # re-frame (3)
- # rewrite-clj (2)
- # shadow-cljs (29)
- # spacemacs (1)
- # sql (4)
- # tools-deps (8)
- # vim (20)
- # yada (7)
@alexmiller cool. yeah, I’m not saying there isn’t ways to hook things up. For manual use, which obviously is the major use case, things have felt natural and I haven’t had to read source etc. For manipulating specs programatically I’m convinced all I want is doable, but it hasn’t felt “natural” and I’ve had to read the implementation to try to grok the explicate/spec/spec* machinery. The map syntax you hint at looks likely to be more intuitive to me, so I like that. Thanks for both helping me across my stumbling block and for keeping on improving spec!
What are the current workarounds for closed spec-like behaviour? I’m trying to retrofit specs to some existing code, and I’d like to ensure that I haven’t missed any cases during development.
In particular, how can I specify a map that should only have the keys I’ve specified?
here’s an example https://github.com/gfredericks/schpec/blob/b2d80cff29861925e7e3407ef3e5de25a90fa7cc/src/com/gfredericks/schpec.clj#L13
Also, I’d like to spec a map which has some standard keyword keys, but also might have string keys with values specified by a spec. Can I do that? Neither s/keys
nor s/map-of
seem to fit that.
You can, but not easily. You can do an s/coll-of :kind map? and then spec the possible mapentry types
It’s tedious
Another path (if you care less about gen) is to use a conformer to keywordize the map then s/keys