File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change 211
211
[& args]
212
212
{:clj-kondo/lint-as 'clojure.core/fn}
213
213
(apply gen-body args))
214
+
215
+ (defmacro let-traced
216
+ " Similar to `clojure.core/let`, but wraps all values in [[trace!]] calls
217
+ addressed via the binding symbol.
218
+
219
+ Example usage:
220
+
221
+ ```clojure
222
+ (def func
223
+ (gen []
224
+ (let-traced [a (gen.distribution/delta \" face\" )
225
+ b (gen.distribution/delta \" cake\" )]
226
+ (str a \" ,\" b))))
227
+
228
+ (into {} (gf/simulate func []))
229
+ ;; => {:a \" face\" :b \" cake\" }
230
+ ```"
231
+ [bindings & body]
232
+ (let [bents (partition 2 bindings)]
233
+ (assert (every? symbol? (map first bents)))
234
+ `(let ~(into []
235
+ (mapcat (fn [[sym expr]]
236
+ [sym `(trace! (quote ~sym) ~@expr)]))
237
+ bents)
238
+ ~@body)))
You can’t perform that action at this time.
0 commit comments