curry.inspect module
Inspect live Curry objects.
- curry.inspect.geticurry(obj)[source]
Gets the ICurry of a module, a type, or a symbol.
A module loaded from its compiled code carries a bill of materials: an IModule whose functions have no body (
IModule.fromBOM). For such a module, and for a function of it, the ICurry is read from the ICurry-JSON file beside the module, and the function is found there by name. The file is read once per module object. A module without the file gives the bill of materials.
- curry.inspect.getimpl(obj)[source]
Gets the implementation of a module or symbol as text.
For a module, the code the backend generates for it (see
curry.save). For a function symbol, the code of its step function. The Python backend gives the generated Python function, or the Python source of a built-in. The C++ backend gives the generated C++ function, read from the .cpp file beside the compiled module, or the bytecode of an interpreted function (flaginterpret) with its constants.- Raises:
ValueError – No code is available: a constructor, a built-in of the C++ runtime, or a function the backend made without a step.
- curry.inspect.getjsonfile(moduleobj)[source]
Returns the file containing ICurry-JSON, if one exists, or None.
- curry.inspect.getsymbol(moduleobj, symbolname)[source]
Looks up a symbol relative to a module.
The name may contain dots. For example, looking up
'List.nub'relative to theDatamodule returnsData.List.nub.- Parameters:
moduleobj – An instance of CurryModule.
symbolname – The symbol name.
- Returns:
A Curry symbol.
- curry.inspect.gettype(moduleobj, typename)[source]
Looks up a type relative to a module.
The name may contain dots. For example, looking up
'SetFunctions.Values'relative to theControlmodule returnsControl.SetFunctions.Values.- Parameters:
moduleobj – An instance of CurryModule.
typename – The type name.
- Returns:
A Curry type.
- curry.inspect.isa(arg, what)[source]
Checks whether the given Curry object is an instance of the given type or constructor. The second argument may be a sequence to check against.
- curry.inspect.symbols(moduleobj, private=False)[source]
Gets the name of each function and constructor symbol defined in a module.
- Parameters:
moduleobj – An instance of CurryModule.
private – Whether to include private symbols.
- Returns:
A dict.