From 3157bb1098ca2bb16e793ec9946885562e3a4e10 Mon Sep 17 00:00:00 2001 From: Marc Weber Date: Sun, 24 May 2009 10:57:46 +0000 Subject: removed all __primops from nixpkgs svn path=/nixpkgs/trunk/; revision=15693 --- pkgs/lib/debug.nix | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'pkgs/lib/debug.nix') diff --git a/pkgs/lib/debug.nix b/pkgs/lib/debug.nix index a58539ee3c4..18b5e1db9d4 100644 --- a/pkgs/lib/debug.nix +++ b/pkgs/lib/debug.nix @@ -1,4 +1,8 @@ -let lib = import ./default.nix; in +let lib = import ./default.nix; + +inherit (builtins) trace attrNamesToStr isAttrs isFunction isList head substring attrNames; + +in rec { @@ -20,20 +24,20 @@ rec { # this can help debug your code as well - designed to not produce thousands of lines - traceShowVal = x : __trace (showVal x) x; - traceShowValMarked = str: x: __trace (str + showVal x) x; - attrNamesToStr = a : lib.concatStringsSep "; " (map (x : "${x}=") (__attrNames a)); + traceShowVal = x : trace (showVal x) x; + traceShowValMarked = str: x: trace (str + showVal x) x; + attrNamesToStr = a : lib.concatStringsSep "; " (map (x : "${x}=") (attrNames a)); showVal = x : - if __isAttrs x then + if isAttrs x then if x ? outPath then "x is a derivation, name ${if x ? name then x.name else ""}, { ${attrNamesToStr x} }" else "x is attr set { ${attrNamesToStr x} }" - else if __isFunction x then "x is a function" + else if isFunction x then "x is a function" else if x == [] then "x is an empty list" - else if __isList x then "x is a list, first item is : ${showVal (__head x)}" + else if isList x then "x is a list, first item is : ${showVal (head x)}" else if x == true then "x is boolean true" else if x == false then "x is boolean false" else if x == null then "x is null" - else "x is probably a string starting, starting characters: ${__substring 0 50 x}.."; + else "x is probably a string starting, starting characters: ${substring 0 50 x}.."; # trace the arguments passed to function and its result traceCall = n : f : a : let t = n2 : x : traceShowValMarked "${n} ${n2}:" x; in t "result" (f (t "arg 1" a)); traceCall2 = n : f : a : b : let t = n2 : x : traceShowValMarked "${n} ${n2}:" x; in t "result" (f (t "arg 1" a) (t "arg 2" b)); -- cgit 1.4.1