tour_of_nix
tour_of_nix copied to clipboard
(builtins.trace el) support
When doing debugging in nix one uses builtins.trace
but the tour currently prints the output to the F12 console and the user can't easily access this.
with import <nixpkgs> { };
with lib;
let
list = ["a" "b" "a" "c" "d" "a"];
intList = [ 1 2 3 ];
countA = l: fold (el: c: if el == "a" then c + 1 else c) 0 l;
mulB = l: lib.fold (el: c: (builtins.trace el) [(el * 2)] ++ c) [8] l;
in
rec {
example = lib.fold (x: y: x + y) "z" ["a" "b" "c"]; #is "abcz"
ex0 = countA list; #should be 3
ex1 = mulB intList; #should be [ 2 4 6 8 ]
}
It would be good to have a pane dedicated to this debug.