query
On this page

genAttrs'

lib.genAttrs'

Docs pulled from | This Revision | 9 minutes ago


Like genAttrs, but allows the name of each attribute to be specified in addition to the value. The applied function should return both the new name and value as a nameValuePair.

In case of attribute name collision the first entry determines the value, all subsequent conflicting entries for the same name are silently ignored.

Inputs

xs

A list of strings s used as generator.

f

A function, given a string s from the list xs, returns a new nameValuePair.

Type

genAttrs' :: [ Any ] -> (Any -> { name :: String; value :: Any; }) -> AttrSet

Examples

lib.attrsets.genAttrs' usage example

genAttrs' [ "foo" "bar" ] (s: nameValuePair ("x_" + s) ("y_" + s))
=> { x_foo = "y_foo"; x_bar = "y_bar"; }
(lib.attrsets.genAttrs')

Noogle detected

Aliases

Implementation

The following is the current implementation of this function.

genAttrs' = xs: f: listToAttrs (map f xs);