diff --git a/nodes/1_lib/source/detangled/1_foundation.nix b/nodes/1_lib/source/detangled/1_foundation.nix index 6b0af00..9ea0f88 100644 --- a/nodes/1_lib/source/detangled/1_foundation.nix +++ b/nodes/1_lib/source/detangled/1_foundation.nix @@ -77,6 +77,25 @@ let isFunction = f: builtins.isFunction f || (f ? __functor && isFunction (f.__functor f)); + /** + Extract the expected function arguments from a function. + This works both with nix-native { a, b ? foo, ... }: style + functions and functions with args set with 'setFunctionArgs'. It + has the same return type and semantics as builtins.functionArgs. + setFunctionArgs : (a → b) → Map String Bool. + + + # Inputs + + `f` + + : 1\. Function argument + */ + functionArgs = f: + if f ? __functor + then f.__functionArgs or (functionArgs (f.__functor f)) + else builtins.functionArgs f; + /** Print a warning before returning the second argument. This function behaves like `builtins.trace`, but requires a string message and formats it as a @@ -107,8 +126,9 @@ let else msg: builtins.trace "warning: ${msg}"; in { - loadStatic = loadStatic; - foldr = foldr; - isFunction = isFunction; - warn = warn; + loadStatic = loadStatic; + foldr = foldr; + isFunction = isFunction; + functionArgs = functionArgs; + warn = warn; } \ No newline at end of file