functionArgs
lib.trivial.functionArgs
Nixpkgs manual
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.
Inputs
f-
1. Function argument
Type
functionArgs : (a -> b) -> { [String] :: Bool }
Nix manual
Return a set containing the names of the formal arguments expected
by the function f. The value of each attribute is a Boolean
denoting whether the corresponding argument has a default value. For
instance, functionArgs ({ x, y ? 123}: ...) = { x = false; y = true; }.
"Formal argument" here refers to the attributes pattern-matched by
the function. Plain lambdas are not included, e.g. functionArgs (x: ...) = { }.
Has constant time complexity.
Noogle detected
Implementation
The following is the current implementation of this function.
f: if f ? __functor then f.__functionArgs or (functionArgs (f.__functor f)) else functionArgs f