Loading lib/lists.nix +6 −4 Original line number Diff line number Diff line Loading @@ -9,7 +9,6 @@ let min id warn pipe ; inherit (lib.attrsets) mapAttrs attrNames; inherit (lib) max; Loading Loading @@ -144,10 +143,13 @@ rec { fold' 0; /** `fold` is an alias of `foldr` for historic reasons `fold` is an alias of `foldr` for historic reasons. ::: {.warning} This function will be removed in 26.05. ::: */ # FIXME(Profpatsch): deprecate? fold = foldr; fold = warn "fold has been deprecated, use foldr instead" foldr; /** “left fold”, like `foldr`, but from the left: Loading lib/tests/misc.nix +6 −9 Original line number Diff line number Diff line Loading @@ -1288,25 +1288,23 @@ runTests { expected = [ 15 ]; }; testFold = testFoldr = let f = op: fold: fold op 0 (range 0 100); # fold with associative operator f = op: foldr: foldr op 0 (range 0 100); # foldr with associative operator assoc = f builtins.add; # fold with non-associative operator # foldr with non-associative operator nonAssoc = f builtins.sub; in { expr = { assocRight = assoc foldr; # right fold with assoc operator is same as left fold # foldr with assoc operator is same as foldl assocRightIsLeft = assoc foldr == assoc foldl; nonAssocRight = nonAssoc foldr; nonAssocLeft = nonAssoc foldl; # with non-assoc operator the fold results are not the same # with non-assoc operator the foldr results are not the same nonAssocRightIsNotLeft = nonAssoc foldl != nonAssoc foldr; # fold is an alias for foldr foldIsRight = nonAssoc fold == nonAssoc foldr; }; expected = { assocRight = 5050; Loading @@ -1314,7 +1312,6 @@ runTests { nonAssocRight = 50; nonAssocLeft = (-5050); nonAssocRightIsNotLeft = true; foldIsRight = true; }; }; Loading nixos/modules/services/matrix/mjolnir.nix +1 −1 Original line number Diff line number Diff line Loading @@ -30,7 +30,7 @@ let moduleConfigFile = pkgs.writeText "module-config.yaml" ( lib.generators.toYAML { } ( lib.filterAttrs (_: v: v != null) ( lib.fold lib.recursiveUpdate { } [ lib.foldr lib.recursiveUpdate { } [ yamlConfig cfg.settings ] Loading pkgs/applications/video/mpv/scripts.nix +1 −1 Original line number Diff line number Diff line Loading @@ -6,7 +6,7 @@ }: let unionOfDisjoints = lib.fold lib.attrsets.unionOfDisjoint { }; unionOfDisjoints = lib.foldr lib.attrsets.unionOfDisjoint { }; addTests = attrPath: drv: Loading Loading
lib/lists.nix +6 −4 Original line number Diff line number Diff line Loading @@ -9,7 +9,6 @@ let min id warn pipe ; inherit (lib.attrsets) mapAttrs attrNames; inherit (lib) max; Loading Loading @@ -144,10 +143,13 @@ rec { fold' 0; /** `fold` is an alias of `foldr` for historic reasons `fold` is an alias of `foldr` for historic reasons. ::: {.warning} This function will be removed in 26.05. ::: */ # FIXME(Profpatsch): deprecate? fold = foldr; fold = warn "fold has been deprecated, use foldr instead" foldr; /** “left fold”, like `foldr`, but from the left: Loading
lib/tests/misc.nix +6 −9 Original line number Diff line number Diff line Loading @@ -1288,25 +1288,23 @@ runTests { expected = [ 15 ]; }; testFold = testFoldr = let f = op: fold: fold op 0 (range 0 100); # fold with associative operator f = op: foldr: foldr op 0 (range 0 100); # foldr with associative operator assoc = f builtins.add; # fold with non-associative operator # foldr with non-associative operator nonAssoc = f builtins.sub; in { expr = { assocRight = assoc foldr; # right fold with assoc operator is same as left fold # foldr with assoc operator is same as foldl assocRightIsLeft = assoc foldr == assoc foldl; nonAssocRight = nonAssoc foldr; nonAssocLeft = nonAssoc foldl; # with non-assoc operator the fold results are not the same # with non-assoc operator the foldr results are not the same nonAssocRightIsNotLeft = nonAssoc foldl != nonAssoc foldr; # fold is an alias for foldr foldIsRight = nonAssoc fold == nonAssoc foldr; }; expected = { assocRight = 5050; Loading @@ -1314,7 +1312,6 @@ runTests { nonAssocRight = 50; nonAssocLeft = (-5050); nonAssocRightIsNotLeft = true; foldIsRight = true; }; }; Loading
nixos/modules/services/matrix/mjolnir.nix +1 −1 Original line number Diff line number Diff line Loading @@ -30,7 +30,7 @@ let moduleConfigFile = pkgs.writeText "module-config.yaml" ( lib.generators.toYAML { } ( lib.filterAttrs (_: v: v != null) ( lib.fold lib.recursiveUpdate { } [ lib.foldr lib.recursiveUpdate { } [ yamlConfig cfg.settings ] Loading
pkgs/applications/video/mpv/scripts.nix +1 −1 Original line number Diff line number Diff line Loading @@ -6,7 +6,7 @@ }: let unionOfDisjoints = lib.fold lib.attrsets.unionOfDisjoint { }; unionOfDisjoints = lib.foldr lib.attrsets.unionOfDisjoint { }; addTests = attrPath: drv: Loading