query
On this page

genAttrs

lib.attrsets.genAttrs

Docs pulled from | This Revision | 38 minutes ago


Generate an attribute set by mapping a function over a list of attribute names.

Inputs

names

Names of values in the resulting attribute set.

f

A function, given the name of the attribute, returns the attribute's value.

Type

genAttrs :: [String] -> (String -> a) -> { [String] :: a }

Examples

lib.attrsets.genAttrs usage example

genAttrs [ "foo" "bar" ] (name: "x_" + name)
=> { foo = "x_foo"; bar = "x_bar"; }

Noogle detected

Aliases

Implementation

The following is the current implementation of this function.

genAttrs = names: f: genAttrs' names (n: nameValuePair n (f n));