query
On this page

mapAttrsRecursive

lib.attrsets.mapAttrsRecursive

Docs pulled from | This Revision | 1 day ago


Like mapAttrs, except that it recursively applies itself to the leaf attributes of a potentially-nested attribute set: the second argument of the function will never be an attrset. Also, the first argument of the mapping function is a list of the attribute names that form the path to the leaf attribute.

For a function that gives you control over what counts as a leaf, see mapAttrsRecursiveCond.

Map over leaf attributes

mapAttrsRecursive (path: value: concatStringsSep "-" (path ++ [value]))
  { n = { a = "A"; m = { b = "B"; c = "C"; }; }; d = "D"; }

evaluates to

{ n = { a = "n-a-A"; m = { b = "n-m-b-B"; c = "n-m-c-C"; }; }; d = "d-D"; }

Type

mapAttrsRecursive :: ([String] -> a -> b) -> AttrSet -> AttrSet

Noogle detected

Aliases

Implementation

The following is the current implementation of this function.

mapAttrsRecursive =
    f:
    set:
    mapAttrsRecursiveCond (as: true) f set;