Skip to content

Commit

Permalink
Fix __std.ci and __std.init
Browse files Browse the repository at this point in the history
  • Loading branch information
whs-dot-hk authored and blaggacao committed Sep 6, 2023
1 parent 218a7f5 commit 3e897a1
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion grow/grow-on.nix
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,43 @@ Example use:
}
```
*/
let
inherit (builtins) head;
inherit (builtins) isAttrs;
inherit (builtins) length;
inherit (l.lists) elemAt;
inherit (l.lists) flatten;
inherit (l.lists) take;

g = p: l: r: v: let
attrPath = take 2 p;
v1 = !(isAttrs l && isAttrs r);
v2 = if attrPath == ["__std" "ci"] || attrPath == ["__std" "init"] then flatten v else head v;
in [v1 v2];

recursiveUpdateUntil =
g:
lhs:
rhs:
let f = attrPath:
l.zipAttrsWith (n: values:
let
a = g here (elemAt values 1) (head values) values;
here = attrPath ++ [n];
in
if length values == 1 || head a then
elemAt a 1
else
f here values
);
in f [] [rhs lhs];
recursiveUpdate =
lhs:
rhs:
recursiveUpdateUntil g lhs rhs;
in
args:
grow args
// {
__functor = l.flip l.recursiveUpdate;
__functor = l.flip recursiveUpdate;
}

0 comments on commit 3e897a1

Please sign in to comment.