From e917282535650ef40b232c8b81081b11d14ce8c3 Mon Sep 17 00:00:00 2001 From: Marc Weber Date: Fri, 6 Mar 2009 23:21:09 +0000 Subject: [PATCH] added eqStrict (deep, strict test for equality) it can replace eqList and can compare attrs as well svn path=/nixpkgs/trunk/; revision=14423 --- pkgs/lib/misc.nix | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/pkgs/lib/misc.nix b/pkgs/lib/misc.nix index 548b8d22edf..1d43918ce56 100644 --- a/pkgs/lib/misc.nix +++ b/pkgs/lib/misc.nix @@ -382,4 +382,17 @@ rec { ["flags" "cfg" "mergeAttrBy" "fixed" ]; # fixed may be passed as fix argument or such -} \ No newline at end of file + # 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 ! +} +