forked from auxolotl/core
add functionArgs
This commit is contained in:
parent
415acdce94
commit
2613fed53e
|
@ -77,6 +77,25 @@ let
|
||||||
isFunction = f: builtins.isFunction f ||
|
isFunction = f: builtins.isFunction f ||
|
||||||
(f ? __functor && isFunction (f.__functor 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
|
Print a warning before returning the second argument. This function behaves
|
||||||
like `builtins.trace`, but requires a string message and formats it as a
|
like `builtins.trace`, but requires a string message and formats it as a
|
||||||
|
@ -107,8 +126,9 @@ let
|
||||||
else msg: builtins.trace "[1;31mwarning: ${msg}[0m";
|
else msg: builtins.trace "[1;31mwarning: ${msg}[0m";
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
loadStatic = loadStatic;
|
loadStatic = loadStatic;
|
||||||
foldr = foldr;
|
foldr = foldr;
|
||||||
isFunction = isFunction;
|
isFunction = isFunction;
|
||||||
warn = warn;
|
functionArgs = functionArgs;
|
||||||
|
warn = warn;
|
||||||
}
|
}
|
Loading…
Reference in a new issue