refactor(sterni/nix/fun): key can also be an int

Change-Id: Ia27be70ef07d9aa7d13821a2808ded9cf16506c8
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7073
Reviewed-by: sterni <sternenseemann@systemli.org>
Autosubmit: sterni <sternenseemann@systemli.org>
Tested-by: BuildkiteCI
This commit is contained in:
sterni 2022-10-23 23:03:49 +02:00 committed by clbot
parent 89aee6443c
commit dfa4c4847c

View file

@ -192,20 +192,18 @@ let
# and the list of arguments to pass to be found in args. # and the list of arguments to pass to be found in args.
startSet = [ startSet = [
{ {
key = "0"; key = 0;
id = 0;
final = false; final = false;
inherit args; inherit args;
} }
]; ];
operator = operator =
{ id, final, ... }@state: { key, final, ... }@state:
let let
# Plumbing to make genericClosure happy # Plumbing to make genericClosure happy
newIds = { newId = {
key = toString (id + 1); key = key + 1;
id = id + 1;
}; };
# Perform recursion step # Perform recursion step
@ -215,10 +213,10 @@ let
# otherwise signal that we're done. # otherwise signal that we're done.
newState = newState =
if builtins.isAttrs call && call.__tailCall or false if builtins.isAttrs call && call.__tailCall or false
then newIds // { then newId // {
final = false; final = false;
inherit (call) args; inherit (call) args;
} else newIds // { } else newId // {
final = true; final = true;
value = call; value = call;
}; };