feat(lib): init genFuse

This commit is contained in:
catvayor 2025-02-06 10:12:59 +01:00
parent 85374e9d6c
commit ecb6b54b9e
Signed by untrusted user: lbailly
GPG key ID: CE3E645251AC63F3

View file

@ -49,6 +49,24 @@ rec {
attrsList:
fuseAttrs (builtins.map f attrsList);
/*
Generate an `attrsList` of given size with the generator before fusing
the resulting list of attribute sets.
Type: (Int -> attrs) -> Int -> attrs
Example:
f = s: { "a${toString s}" = s + s; }
genFuse f 3
=> { a0 = 0; a1 = 2; a2 = 4; }
*/
genFuse =
# Int -> attrs
f:
# Int
size:
fuseAttrs (builtins.genList f size);
/*
Equivalent of lib.singleton but for an attribute set.