Last active
January 8, 2020 16:39
-
-
Save madstap/0e3e167c90fdd59ee61452debd577175 to your computer and use it in GitHub Desktop.
Debugging let
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; 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