lib: add lazy functor
This commit is contained in:
parent
749ccedb6a
commit
89a55b45be
1 changed files with 11 additions and 0 deletions
|
@ -48,6 +48,17 @@ rec {
|
||||||
};
|
};
|
||||||
|
|
||||||
spread = function: list: if list == [ ] then function else spread (function (head list)) (tail list);
|
spread = function: list: if list == [ ] then function else spread (function (head list)) (tail list);
|
||||||
|
|
||||||
|
# Takes a function and makes it lazy, by consuming arguments and applying it to the inner function first
|
||||||
|
# before calling the original function
|
||||||
|
lazy = func: inner: {
|
||||||
|
inherit func;
|
||||||
|
app = inner;
|
||||||
|
__functor = self: input:
|
||||||
|
let app = self.app input; in
|
||||||
|
if (typeOf app) == "lambda" then self // { inherit app; }
|
||||||
|
else self.func app;
|
||||||
|
};
|
||||||
} // (
|
} // (
|
||||||
import ./digga.nix { inherit lib; }
|
import ./digga.nix { inherit lib; }
|
||||||
) // (
|
) // (
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue