-
Notifications
You must be signed in to change notification settings - Fork 9
Home
Brian Marick edited this page Mar 20, 2016
·
73 revisions
Internally, the library works with canonical type descriptions. A canonical type description is just a map with paths as keys and vectors of functions (checkers) as values.
Each path is used to descend into a whole value to discover a set of leaf values that are checked by the checkers.
- Path elements (what can be in the left-hand side)
- Checkers (what can be in the right-hand side)
The happy case is when the path matches the whole value's structure. What happens, though, when the next path element is :a
and the next bit of the structure isn't associative? Or if the next bit is a map but it doesn't have an :a
key?
Although you can, and often do, use canonical type descriptions, you'll often instead compose them out of a sequence of condensed type descriptions, such as this:
(type! :X record? {:a even?} (requires :a :b))
- Rejecting nil and missing values
- Paths from maps where checkers belong
- Explicitly branching paths
- Describing the whole value
- Rejecting extra keys
- Helpful error messages from anonymous checkers
- Behind the scenes: How checking and type definition works
- [[The
implies
predicate]]