debug.nix: deprecate strict
Replace the implementation by seq and add a deprecation warning. The semantics seems a little bit off, but the function should only be used for debugging.
This commit is contained in:
parent
6889f53397
commit
93bbe13f98
|
@ -73,27 +73,9 @@ rec {
|
||||||
# usage: { testX = allTrue [ true ]; }
|
# usage: { testX = allTrue [ true ]; }
|
||||||
testAllTrue = expr : { inherit expr; expected = map (x: true) expr; };
|
testAllTrue = expr : { inherit expr; expected = map (x: true) expr; };
|
||||||
|
|
||||||
# evaluate everything once so that errors will occur earlier
|
strict = v:
|
||||||
# hacky: traverse attrs by adding a dummy
|
trace "Warning: strict is deprecated and will be removed in the next release"
|
||||||
# ignores functions (should this behavior change?) See strictf
|
(builtins.seq v v);
|
||||||
#
|
|
||||||
# Note: This should be a primop! Something like seq of haskell would be nice to
|
|
||||||
# have as well. It's used fore debugging only anyway
|
|
||||||
strict = x :
|
|
||||||
let
|
|
||||||
traverse = x :
|
|
||||||
if isString x then true
|
|
||||||
else if isAttrs x then
|
|
||||||
if x ? outPath then true
|
|
||||||
else all id (mapAttrsFlatten (n: traverse) x)
|
|
||||||
else if isList x then
|
|
||||||
all id (map traverse x)
|
|
||||||
else if isBool x then true
|
|
||||||
else if isFunction x then true
|
|
||||||
else if isInt x then true
|
|
||||||
else if x == null then true
|
|
||||||
else true; # a (store) path?
|
|
||||||
in if traverse x then x else throw "else never reached";
|
|
||||||
|
|
||||||
# example: (traceCallXml "myfun" id 3) will output something like
|
# example: (traceCallXml "myfun" id 3) will output something like
|
||||||
# calling myfun arg 1: 3 result: 3
|
# calling myfun arg 1: 3 result: 3
|
||||||
|
|
Loading…
Reference in New Issue