mapAttrs'
lib.mapAttrs' (Prime)
Docs pulled from | This Revision | 17 minutes ago
Like mapAttrs
, but allows the name of each attribute to be
changed in addition to the value. The applied function should
return both the new name and value as a nameValuePair
.
Inputs
f
-
A function, given an attribute's name and value, returns a new
nameValuePair
. set
-
Attribute set to map over.
Type
mapAttrs' :: (String -> Any -> { name :: String; value :: Any; }) -> AttrSet -> AttrSet
Examples
lib.attrsets.mapAttrs'
usage example
mapAttrs' (name: value: nameValuePair ("foo_" + name) ("bar-" + value))
{ x = "a"; y = "b"; }
=> { foo_x = "bar-a"; foo_y = "bar-b"; }