February 2018
Intermediate to advanced
304 pages
7h 11m
English
Specs are logical compositions of predicates (functions returning a logical true/false value) used to describe a set of data values. The spec library provides operations to create, combine, and register specs.
To work with spec, you’ll need to load the namespace clojure.spec.alpha, which is commonly aliased to s. All spec examples in this chapter use the s alias to refer to functions or macros from the clojure.spec library.
| | (require '[clojure.spec.alpha :as s]) |
The s/def macro names and registers a spec in the global registry of specs accessible in the current Clojure program. The syntax for s/def is:
| | (s/def name spec) |
Spec names are qualified keywords. For example, a simple spec definition using a predicate spec looks like: ...
Read now
Unlock full access