Above and beyond type systems with clojure.spec
summary
Clojure 1.9’s clojure.spec lets code express runtime constraints, not compile time types, and attaches specs to functions so wrong inputs raise exceptions instead of silently returning nil. The demo shows a hello-user function, using instrument to enable checks, a custom non-blank-string predicate, a multi-spec dispatch for authenticate that validates two different return shapes based on authenticated true/false, and generators that produce valid JWT tokens for generative testing. Specs run in production for boundary checks and give explainable failure messages.
AI-written summary · about
chapters (9)
- 0:00Start
- 2:59clojure.spec?
- 3:39What spec is...
- 6:05A Clojure primer
- 8:32We start with a predicate
- 9:19Attach the spec to a function
- 18:26Function spec at its finest
- 20:09Greeting a JWT-authenticated user
- 32:57Philosophy and philology of








