File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11# Changelog
22
3+ ## v0.97.5 — clojure.spec.alpha Introspection Utilities
4+
5+ ` clojure.spec.alpha ` gains the two canon introspection helpers:
6+
7+ - ` abbrev ` — strips namespace qualifiers from symbols and shortens
8+ ` (fn [%] body) ` to ` body ` , so spec forms read cleanly in
9+ diagnostics.
10+ - ` describe ` — returns ` (abbrev (form spec)) ` , the canonical
11+ human-readable description of a registered or anonymous spec.
12+
13+ The namespace now requires ` [clojure.walk :as walk] ` . Generators
14+ (` gen ` , ` exercise ` ) continue to throw ` :mino/unsupported ` .
15+
316## v0.97.4 — Lift defn So Top-Of-File Predicates Use It
417
518` defn ` , ` defn- ` , ` defonce ` , and the private ` fn-arity-with-prepost `
Original file line number Diff line number Diff line change 1717; ; special-form dispatch and fire the macros instead, leaving the var
1818; ; unbound.
1919
20- (ns clojure.spec.alpha )
20+ (ns clojure.spec.alpha
21+ (:require [clojure.walk :as walk]))
2122
2223(def ^:private registry-ref (atom {}))
2324
136137 (and (map? x) (::form x)) (::form x)
137138 :else ::unknown ))
138139
140+ (defn abbrev
141+ " Return an abbreviated description of a spec form. Strips namespace
142+ qualifiers from symbols and shortens (fn [%] body) to body."
143+ [form]
144+ (cond
145+ (seq? form)
146+ (walk/postwalk
147+ (fn [f]
148+ (cond
149+ (and (symbol? f) (namespace f))
150+ (symbol (name f))
151+
152+ (and (seq? f) (= 'fn (first f)) (= '[%] (second f)))
153+ (last f)
154+
155+ :else f))
156+ form)
157+
158+ (symbol? form)
159+ (symbol (name form))
160+
161+ :else form))
162+
163+ (defn describe
164+ " Return an abbreviated description of the spec as data."
165+ [spec]
166+ (abbrev (form spec)))
167+
139168; ; ---------------------------------------------------------------------------
140169; ; pred -- bare predicates promoted to specs.
141170; ; ---------------------------------------------------------------------------
Original file line number Diff line number Diff line change 2727 */
2828#define MINO_VERSION_MAJOR 0
2929#define MINO_VERSION_MINOR 97
30- #define MINO_VERSION_PATCH 4
30+ #define MINO_VERSION_PATCH 5
3131
3232/*
3333 * Human-readable version string of the *linked* runtime, e.g. "0.48.0".
You can’t perform that action at this time.
0 commit comments