Fork me on GitHub
#clojure-spec
<
2019-08-18
>
sundbp20:08:13

@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!

cfleming23:08:06

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.

cfleming23:08:23

In particular, how can I specify a map that should only have the keys I’ve specified?

cfleming23:08:37

Awesome, thanks!

cfleming23:08:36

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.

Alex Miller (Clojure team)23:08:52

You can, but not easily. You can do an s/coll-of :kind map? and then spec the possible mapentry types

Alex Miller (Clojure team)23:08:16

Another path (if you care less about gen) is to use a conformer to keywordize the map then s/keys

cfleming23:08:32

Yeah, I don’t care about gen in this case.

cfleming23:08:42

Just trying to spec an existing system.