I'm trying to map it onto my experience with Clojure and plumatic/schema, but nothing is clicking.
I'm trying to map it onto my experience with Clojure and plumatic/schema, but nothing is clicking.
In spec, you specify that a first-name attribute is a string and an email attribute matches some regex. Those are specifications about the attributes and can be used across many entity types. A person entity spec is then defined as a map that contains a set of required or optional attributes. A company entity spec is a different map with different attributes, some of which might be shared with a person (like email address).
This is in many ways a shift in perspective, allowing you to start defining and reusing attribute specs to a much greater degree.
The use of structural systems with mathematical properties (regular expressions for sequence structure and sets for map keys) turns out to have many useful effects in computing error sets, etc.
In Schema, you would represent a map's spec like this:
(def my-map {:a s/Str :b s/Int})
In spec, you'd do it like this: (s/def ::a string?)
(s/def ::b integer?)
(s/def ::my-map (s/keys :req [::a ::b]))
In other words, the values are specified separately from the keys. This promotes reuse of specs, which is important especially as they get more complex.