clojure.spec contracts for the Result monad.
Applies type-theoretic best practices via spec:
References:
clojure.spec contracts for the Result monad. Applies type-theoretic best practices via spec: - Sum types: Result = Ok | Err (discriminated union via :ok/:error keys) - Smart constructors: ok/err are the only valid constructors - Making illegal states unrepresentable: a Result is EITHER ok? OR err?, never both - Totality: all functions are total (never throw) - Functor/Monad laws enforced by property tests References: - Wlaschin: Domain Modeling Made Functional (algebraic types, smart constructors) - Brady: Type-Driven Development (type-define-refine, totality) - Uncle Bob: Functional Design Ch10 (spec = best of static + dynamic) - clojure.org/guides/spec
(instrument!)Enable spec checking on all Result DSL functions. Use in dev/test, not production (performance cost). Note: macros (let-ok, try-effect, try-effect*) have fdef specs but cannot be instrumented (compile-time expansion).
Enable spec checking on all Result DSL functions. Use in dev/test, not production (performance cost). Note: macros (let-ok, try-effect, try-effect*) have fdef specs but cannot be instrumented (compile-time expansion).
(unstrument!)Disable spec checking (restore production performance).
Disable spec checking (restore production performance).
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |