lib: attrs: document functions
This commit is contained in:
parent
bd53470e46
commit
e0b0f44a9a
|
@ -1,9 +1,21 @@
|
||||||
{ lib, ... }:
|
{ lib, ... }:
|
||||||
let
|
let
|
||||||
inherit (lib) filterAttrs mapAttrs';
|
inherit (lib) filterAttrs listToAttrs mapAttrs';
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
# Filter a generated set of attrs using a predicate function.
|
||||||
|
#
|
||||||
|
# mapFilterAttrs ::
|
||||||
|
# (name -> value -> bool)
|
||||||
|
# (name -> value -> { name = any; value = any; })
|
||||||
|
# attrs
|
||||||
mapFilterAttrs = pred: f: attrs: filterAttrs pred (mapAttrs' f attrs);
|
mapFilterAttrs = pred: f: attrs: filterAttrs pred (mapAttrs' f attrs);
|
||||||
|
|
||||||
|
# Generate an attribute set by mapping a function over a list of values.
|
||||||
|
#
|
||||||
|
# genAttrs' ::
|
||||||
|
# [ values ]
|
||||||
|
# (value -> { name = any; value = any; })
|
||||||
|
# attrs
|
||||||
genAttrs' = values: f: listToAttrs (map f values);
|
genAttrs' = values: f: listToAttrs (map f values);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue