refactor(read-tree): Idiomatic 'attrsToList' instead of weird hack

This commit is contained in:
Vincent Ambo 2019-11-25 15:10:31 +00:00
parent f1655c5cbb
commit 48ed487bdd

View file

@ -3,7 +3,6 @@ path: { pkgs, ... } @ args:
let let
inherit (builtins) inherit (builtins)
attrNames attrNames
attrValues
filter filter
head head
isString isString
@ -11,19 +10,13 @@ let
map map
match match
readDir readDir
tail
toPath toPath
toString; toString;
zipAttrs = names: values: attrsToList = attrs: map (name: {
if (names == []) || (values == []) inherit name;
then [] value = attrs."${name}";
else [{ }) (attrNames attrs);
name = head names;
value = head values;
}] ++ zipAttrs (tail names) (tail values);
attrsToList = attrs: zipAttrs (attrNames attrs) (attrValues attrs);
isFile = s: s == "regular"; isFile = s: s == "regular";
isDir = s: s == "directory"; isDir = s: s == "directory";