diff options
author | Ben Siraphob <bensiraphob@gmail.com> | 2021-01-25 13:57:48 +0700 |
---|---|---|
committer | Ben Siraphob <bensiraphob@gmail.com> | 2021-01-26 10:57:07 +0700 |
commit | 1c2a2b0a0848d58407fb4ff73a8dc1e854f5a270 (patch) | |
tree | 1bdff74d3f609e78f8931a3f32398062d61db84d /lib/attrsets.nix | |
parent | aa8868c7cca8d30706a68a876d048968c83e1cf1 (diff) |
treewide: fold -> foldr
Diffstat (limited to 'lib/attrsets.nix')
-rw-r--r-- | lib/attrsets.nix | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/attrsets.nix b/lib/attrsets.nix index d91d7a0cd47e6..d8bc73ca87477 100644 --- a/lib/attrsets.nix +++ b/lib/attrsets.nix @@ -5,7 +5,7 @@ let inherit (builtins) head tail length; inherit (lib.trivial) and; inherit (lib.strings) concatStringsSep sanitizeDerivationName; - inherit (lib.lists) fold concatMap concatLists; + inherit (lib.lists) fold foldr concatMap concatLists; in rec { @@ -152,8 +152,8 @@ rec { => { a = [ 2 3 ]; } */ foldAttrs = op: nul: list_of_attrs: - fold (n: a: - fold (name: o: + foldr (n: a: + foldr (name: o: o // { ${name} = op n.${name} (a.${name} or nul); } ) a (attrNames n) ) {} list_of_attrs; @@ -433,7 +433,7 @@ rec { => true */ matchAttrs = pattern: attrs: assert isAttrs pattern; - fold and true (attrValues (zipAttrsWithNames (attrNames pattern) (n: values: + foldr and true (attrValues (zipAttrsWithNames (attrNames pattern) (n: values: let pat = head values; val = head (tail values); in if length values == 1 then false else if isAttrs pat then isAttrs val && matchAttrs pat val |