summaryrefslogtreecommitdiffstats
path: root/lib/debug.nix
diff options
context:
space:
mode:
Diffstat (limited to 'lib/debug.nix')
-rw-r--r--lib/debug.nix22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/debug.nix b/lib/debug.nix
index ea6aed60ab43..e3ca3352397e 100644
--- a/lib/debug.nix
+++ b/lib/debug.nix
@@ -148,6 +148,28 @@ rec {
/* A combination of `traceVal` and `traceSeqN`. */
traceValSeqN = traceValSeqNFn id;
+ /* Trace the input and output of a function `f` named `name`,
+ both down to `depth`.
+
+ This is useful for adding around a function call,
+ to see the before/after of values as they are transformed.
+
+ Example:
+ traceFnSeqN 2 "id" (x: x) { a.b.c = 3; }
+ trace: { fn = "id"; from = { a.b = {…}; }; to = { a.b = {…}; }; }
+ => { a.b.c = 3; }
+ */
+ traceFnSeqN = depth: name: f: v:
+ let res = f v;
+ in lib.traceSeqN
+ (depth + 1)
+ {
+ fn = name;
+ from = v;
+ to = res;
+ }
+ res;
+
# -- TESTING --