Skip to content

Instantly share code, notes, and snippets.

@madstap
Last active January 8, 2020 16:39
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 madstap/0e3e167c90fdd59ee61452debd577175 to your computer and use it in GitHub Desktop.
Save madstap/0e3e167c90fdd59ee61452debd577175 to your computer and use it in GitHub Desktop.
Debugging let
;; A macro for debugging stuff that happens inside a let
;; just change let to lets and all the bindings will be defined
;; as globals instead of locals and the body will be ignored.
(require '[madstap.comfy :refer [defs]])
(require '[integrant.core :as ig])
(defmacro lets
{:style/indent 1}
[bindings & _body]
`(do ~@(map (fn [[b exp]] `(madstap.comfy/defs ~b ~exp)) (partition 2 bindings))))
;; executes body
(defmacro lete
{:style/indent 1}
[bindings & body]
`(do ~@(map (fn [[b exp]] `(madstap.comfy/defs ~b ~exp)) (partition 2 bindings))
~@body))
(defmacro defd-system
{:style/indent 1}
[[binding config] & _body]
`(let [sys# (ig/init ~config)]
(defs ~binding sys#)
(def ~'defdsys sys#)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment