From af317ac156f882e5d2ef0370a48fb0345d7ce008 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Sat, 3 Apr 2021 17:12:34 +0000 Subject: [PATCH] lib: attrs: document functions --- lib/attrs.nix | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/attrs.nix b/lib/attrs.nix index 17ed3bf..7b86aaa 100644 --- a/lib/attrs.nix +++ b/lib/attrs.nix @@ -1,9 +1,21 @@ { lib, ... }: let - inherit (lib) filterAttrs mapAttrs'; + inherit (lib) filterAttrs listToAttrs mapAttrs'; 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); + # 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); }