forked from auxolotl/core
start detangling lib
This commit is contained in:
parent
9cb4ed1ffc
commit
a4c9fde3e9
|
@ -4,32 +4,38 @@
|
||||||
* for new functions in `./tests.nix`.
|
* for new functions in `./tests.nix`.
|
||||||
*/
|
*/
|
||||||
let
|
let
|
||||||
loadStatic = (folder:
|
foundation = import ./detangled/1_foundation.nix;
|
||||||
{
|
fixedPoints = import ./detangled/2_fixed-points.nix;
|
||||||
setup = builtins.fromTOML ( builtins.readFile "${folder}/static/setup.toml" );
|
in
|
||||||
meta = builtins.fromTOML ( builtins.readFile "${folder}/static/meta.toml" );
|
let
|
||||||
}
|
static = foundation.loadStatic ../.;
|
||||||
);
|
untangledBase = {
|
||||||
static = loadStatic ../.;
|
|
||||||
untangledLib = {
|
|
||||||
# constants
|
# constants
|
||||||
sourceTypes = static.setup.sourceTypes;
|
sourceTypes = static.setup.sourceTypes;
|
||||||
licenses = static.setup.licenses;
|
licenses = static.setup.licenses;
|
||||||
maintainers = static.setup.maintainers;
|
maintainers = static.setup.maintainers;
|
||||||
teams = static.setup.teams;
|
teams = static.setup.teams;
|
||||||
|
|
||||||
builtins = builtins;# just to be overridable
|
# just to be overridable
|
||||||
loadStatic = loadStatic;
|
builtins = builtins;
|
||||||
|
|
||||||
|
# top level helpers
|
||||||
|
loadStatic = foundation.loadStatic;
|
||||||
|
foldr = foundation.foldr;
|
||||||
|
|
||||||
|
# namespaces
|
||||||
|
fixedPoints = fixedPoints;
|
||||||
};
|
};
|
||||||
|
|
||||||
inherit (import ./fixed-points.nix { inherit lib; }) makeExtensible;
|
#
|
||||||
|
# legacy lib
|
||||||
lib = makeExtensible (self: let
|
#
|
||||||
|
lib = fixedPoints.makeExtensible (self: let
|
||||||
callLibs = file: import file { lib = self; };
|
callLibs = file: import file { lib = self; };
|
||||||
in untangledLib // {
|
in untangledBase // {
|
||||||
|
fixedPoints = fixedPoints;
|
||||||
# often used, or depending on very little
|
# often used, or depending on very little
|
||||||
trivial = callLibs ./trivial.nix;
|
trivial = callLibs ./trivial.nix;
|
||||||
fixedPoints = callLibs ./fixed-points.nix;
|
|
||||||
|
|
||||||
# datatypes
|
# datatypes
|
||||||
attrsets = callLibs ./attrsets.nix;
|
attrsets = callLibs ./attrsets.nix;
|
||||||
|
|
22
nodes/1_lib/source/detangled/1_foundation.nix
Normal file
22
nodes/1_lib/source/detangled/1_foundation.nix
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
#
|
||||||
|
# foundation contains functions that only depend on builtins
|
||||||
|
#
|
||||||
|
{
|
||||||
|
loadStatic = (folder:
|
||||||
|
{
|
||||||
|
setup = builtins.fromTOML ( builtins.readFile "${folder}/static/setup.toml" );
|
||||||
|
meta = builtins.fromTOML ( builtins.readFile "${folder}/static/meta.toml" );
|
||||||
|
}
|
||||||
|
);
|
||||||
|
foldr = (
|
||||||
|
op: nul: list:
|
||||||
|
let
|
||||||
|
len = builtins.length list;
|
||||||
|
fold' = n:
|
||||||
|
if n == len
|
||||||
|
then nul
|
||||||
|
else op (builtins.elemAt list n) (fold' (n + 1));
|
||||||
|
in
|
||||||
|
fold' 0
|
||||||
|
);
|
||||||
|
}
|
|
@ -1,4 +1,6 @@
|
||||||
{ foldr }:
|
let # internal lib dependencies
|
||||||
|
foundation = import ./1_foundation.nix;
|
||||||
|
in
|
||||||
let
|
let
|
||||||
/*
|
/*
|
||||||
`fix f` computes the fixed point of the given function `f`. In other words, the return value is `x` in `x = f x`.
|
`fix f` computes the fixed point of the given function `f`. In other words, the return value is `x` in `x = f x`.
|
||||||
|
@ -274,7 +276,7 @@
|
||||||
```
|
```
|
||||||
*/
|
*/
|
||||||
composeManyExtensions =
|
composeManyExtensions =
|
||||||
foldr (x: y: composeExtensions x y) (final: prev: {});
|
foundation.foldr (x: y: composeExtensions x y) (final: prev: {});
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Same as `makeExtensible` but the name of the extending attribute is
|
Same as `makeExtensible` but the name of the extending attribute is
|
Loading…
Reference in a new issue