Create a ->/->>/some->/some->> replacement such that if any member of the chain fails, all previous members' (inclusive) arguments and return values are printlned.
This would greatly improve the debuggability of Clojure programs, and foster usage of threading macros, which are superior to call chains for a number of reasons.
Example:
Given (-> x f1 (f2 some-arg) f3)
If f2 throws an error
The following is printed:
The (-> x f1 (f2 some-arg) f3) chain failed at f2.
f1 execution:
Input:
{:a 2}
Output:
{:a 3000}
f2 execution:
Input:
{:a 3000},
::some-argument
Exception:
FooBarException
The implementation should observe clojure.core/*assert*:
if true, do as above
else, expand to clojure.core/->
i.e. zero-cost abstraction
Considerations
Should be a .cljc library, since .cljs compat as an afterthought can be harder
printlned values should have a limit
huge vals can degrade IDE/term performance
particularly true for infinite seqs
maybe some heuristic for detection is possible
Perhaps some 'rate-limiting' is necessary
e.g. one println should happen at most for a given 10s window
else, exceptions triggered (and caught) within loops might cause repetitive output
println should be the default "print function", but there should be a configurable print-function
e.g. (alter-var-root #'the/print-fn (constantly timbre/debug))
Create a ->/->>/some->/some->> replacement such that if any member of the chain fails, all previous members' (inclusive) arguments and return values are
println
ed.This would greatly improve the debuggability of Clojure programs, and foster usage of threading macros, which are superior to call chains for a number of reasons.
Example:
(-> x f1 (f2 some-arg) f3)
f2
throws an errorThe implementation should observe
clojure.core/*assert*
:clojure.core/->
Considerations
println
ed values should have a limitprintln
should happen at most for a given 10s windowprintln
should be the default "print function", but there should be a configurable print-function(alter-var-root #'the/print-fn (constantly timbre/debug))