clojure-spec

About: http://clojure.org/about/spec Guide: http://clojure.org/guides/spec API: https://clojure.github.io/spec.alpha/clojure.spec.alpha-api.html
2020-05-14T17:10:25.406500Z

this is super useful, thanks for the post! I have a use case where I want to generate some crud operations as well for some map specs - do you have any pointers for functions you used to parse the specs? I see s/describe and s/form did you use those or something else?

seancorfield 2020-05-14T17:38:20.406700Z

Just those. To get at the primary list of required/optional keys.

2020-05-14T17:41:31.406900Z

perfect, thanks!

Amir Eldor 2020-05-14T19:08:51.407900Z

How do you define a map spec with keys of similar spec? e.g.:

(s/def potato-name string?)
(s/def potato-happiness number?)

;; This is a potato:
{:name "potato name"
 :happiness-1 12
 :happiness-2 54}
Similarly, I see that (s/keys) requires a fully qualified name for each key and it's strange to me. What if I got two specs with the same key but different specs?

alexmiller 2020-05-14T19:49:38.408700Z

the idea behind spec is to give attributes global semantic meaning, by using namespaced attributes to differentiate and not do that