Skip to content

Commit

Permalink
doc: lib/textClosures
Browse files Browse the repository at this point in the history
  • Loading branch information
hsjobeki committed Oct 28, 2024
1 parent d2dfc1a commit 8a4962e
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions lib/strings-with-deps.nix
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,29 @@ let
concatStringsSep
head
isAttrs
listToAttrs
tail
;
in
rec {

/* !!! The interface of this function is kind of messed up, since
it's way too overloaded and almost but not quite computes a
topological sort of the depstrings. */

/**
:::{.note}
If you are the maintainer or user of this function.
Please document it. Or remove in case it is unused.
:::
:::{.note}
The interface of this function is kind of messed up, since
it's way too overloaded and almost but not quite computes a
topological sort of the depstrings.
:::
*/
textClosureList = predefined: arg:
let
# Types are:
#
# Todo :: [ String | { deps :: Todo; text :: string; } ]
# f :: { ... } -> Todo -> { result :: [ String ]; done :: { ... } }
f = done: todo:
if todo == [] then {result = []; inherit done;}
else
Expand All @@ -69,7 +80,7 @@ rec {
done = y.done;
}
else if done ? ${entry} then f done (tail todo)
else f (done // listToAttrs [{name = entry; value = 1;}]) ([predefined.${entry}] ++ tail todo);
else f (done // { ${entry} = 1; }) ([predefined.${entry}] ++ tail todo);
in (f {} arg).result;

textClosureMap = f: predefined: names:
Expand Down

0 comments on commit 8a4962e

Please sign in to comment.