Skip to content

Instantly share code, notes, and snippets.

@adamdavislee
Last active August 8, 2023 20:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamdavislee/4fd2c07944e113bd030b2a3468b98c48 to your computer and use it in GitHub Desktop.
Save adamdavislee/4fd2c07944e113bd030b2a3468b98c48 to your computer and use it in GitHub Desktop.
;; Custom inspection tool!
;; =======================
(defn appendv
[coll & args]
(apply conj (vec coll) args))
(def *inspections* (atom {}))
(defmacro inspect
[tag]
(let [env# (->> &env (keys) (mapv (juxt str identity)) (into {}))]
`(swap! *inspections* update ~tag appendv ~env#)))
(defmacro for-inspect
[tag & forms]
(vec (map-indexed (fn [index runs]
`(let ~(vec (mapcat
(fn [[k _v]] [`~(symbol k) `(get-in @*inspections* ~[tag index k])])
runs))
~@forms))
(take-last 12 (@*inspections* tag)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment