added eqStrict (deep, strict test for equality)

it can replace eqList and can compare attrs as well

svn path=/nixpkgs/trunk/; revision=14423
This commit is contained in:
Marc Weber 2009-03-06 23:21:09 +00:00
parent d0691bf1d7
commit e917282535

View File

@ -382,4 +382,17 @@ rec {
["flags" "cfg" "mergeAttrBy" "fixed" ]; # fixed may be passed as fix argument or such
}
# deep, strict equality testing. This should be implemented as primop
eqStrict = a : b :
let eqListStrict = a : b :
if (a == []) != (b == []) then false
else if a == [] then true
else eqStrict (__head a) (__head b) && eqListStrict (__tail a) (__tail b);
in
if __isList a && __isList b then eqListStrict a b
else if __isAttrs a && isAttrs b then
(eqListStrict (__attrNames a) (__attrNames b))
&& (eqListStrict (lib.attrValues a) (lib.attrValues b))
else a == b; # FIXME !
}