tvl-depot/users/sterni/nix
sterni 36f6322d16 feat(sterni/nix/fun): implement tail call “optimization” for Nix
I've had the notion that builtins.genericClosure can be used to express
any recursive algorithm, but a proof is much better than a notion of
course! In this case we can easily show this by implementing a function
that converts a tail recursive function into an application of
builtins.genericClosure.

This is possible if the function resolves its self reference using a
fixed point which allows us to pass a function that encodes the call to
self in a returned attribute set, leaving the actual call to
genericClosure's operator. Additionally, some tools for collecting meta
data about functions (argCount) and calling arbitrary functions (apply,
unapply) are necessary.

Change-Id: I7d455db66d0a55e8639856ccc207639d371a5eb8
Reviewed-on: https://cl.tvl.fyi/c/depot/+/5292
Tested-by: BuildkiteCI
Reviewed-by: sterni <sternenseemann@systemli.org>
Autosubmit: sterni <sternenseemann@systemli.org>
2022-02-15 12:52:19 +00:00
..
char style: format entire depot with nixpkgs-fmt 2022-01-31 16:11:53 +00:00
flow style: format entire depot with nixpkgs-fmt 2022-01-31 16:11:53 +00:00
fun feat(sterni/nix/fun): implement tail call “optimization” for Nix 2022-02-15 12:52:19 +00:00
html style: format entire depot with nixpkgs-fmt 2022-01-31 16:11:53 +00:00
int style: format entire depot with nixpkgs-fmt 2022-01-31 16:11:53 +00:00
string style: format entire depot with nixpkgs-fmt 2022-01-31 16:11:53 +00:00
url style: format entire depot with nixpkgs-fmt 2022-01-31 16:11:53 +00:00
utf8 style: format entire depot with nixpkgs-fmt 2022-01-31 16:11:53 +00:00