curry.icurry.analysis.aliases module
Finds alias functions.
An alias is a function whose body is one call of another function on exactly its own parameters, in order:
f x y = g x y
The Prelude’s instance methods for Int arithmetic and comparison are aliases (i1 <= i2 = ltEqInt i1 i2; the +, -, and * wrappers). A call of an alias costs a rewrite step and a node that a direct call of the target does not. The optimizer replaces such calls; see curry.interpreter.optimize.inline_aliases.
- curry.icurry.analysis.aliases.alias_target(ifun)[source]
The full name of the function that
ifunis an alias of, or None. The answer comes from the metadata when it is there (a module loaded from its compiled form), else from the body.
- curry.icurry.analysis.aliases.alias_target_of_body(ifun)[source]
The full name of the function that
ifunis an alias of, read from its body, or None. A function without a Curry body (built-in, external, or loaded from its compiled form) is never an alias by this test.
- curry.icurry.analysis.aliases.lookup_function(symbolname, modules)[source]
Finds the IFunction named by the full name
symbolnameamong the loaded modules.modulesmaps module names to Curry modules and packages, as Interpreter.modules does. Returns None when the module is not loaded or has no such function.
- curry.icurry.analysis.aliases.resolve_alias(symbolname, modules, nargs)[source]
Follows aliases from the function named
symbolname, called withnargsarguments, to the function that does the work. Returns the full name of that function:symbolnameitself when it is not an alias, when its module is not loaded, or when the call is not saturated. A chain stops before a target that is not loaded or that has another arity. A chain that closes on itself (aliases of each other) leaves the call alone.