Skip to content

Commit 6f4165b

Browse files
leifericfclaude
andcommitted
Bump to v0.97.5: clojure.spec.alpha abbrev/describe
Adds the two canon introspection helpers that the spec.alpha audit flagged. Generators (gen, exercise) continue to throw :mino/unsupported. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 2df4eaf commit 6f4165b

3 files changed

Lines changed: 44 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
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`

lib/clojure/spec/alpha.clj

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
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

@@ -136,6 +137,34 @@
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
;; ---------------------------------------------------------------------------

src/mino.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
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".

0 commit comments

Comments
 (0)