curry.toolchain package
Code for finding and converting Curry source.
Contains functions for invoking the toolchain to build ICurry and ICurry-JSON files. The following file types are used:
Suffix External Tool Description
+-------- +-------------- +---------------------------------------
.curry Curry source code.
.icy Curry front end ICurry code in Curry format. The front
end writes FlatCurry; the translation to
ICurry is built in (flat2icurry). The
icurry program is the alternative.
.json[.z] ICurry code in JSON format [compressed].
.py Curry compiled to Python.
.cpp Curry compiled to C++.
.so C++ compiler C++ Curry compiled to a shared object.
- curry.toolchain.compile_seconds()[source]
The seconds this process has spent in the steps of the toolchain. Zero when every file was current.
- curry.toolchain.currentfile(plan, name, currypath, is_sourcefile=False, **ignored)[source]
Finds the newest prerequisite along the Curry build pipeline.
The file returned is the newest among the Curry source file (suffix: .curry), the ICurry file (suffix: .icy), the JSON file (suffix: .json or .json.z), and the files of the backend (suffix: .py; or .cpp and .so), less the files that a step of the plan refuses (see
Plan.prune_stale) and the files made from them. The files are compared by modification time (seefilesys.newer), so a step that moves the change times of the inodes (a chmod, a rename, the prefix patch of a package manager) does not make a product stale.- Parameters:
plan – The compile plan.
name – The module, source file, or package name.
currypath – A sequence of paths to search (i.e., CURRYPATH split on ‘:’).
is_sourcefile – Indicates whether to interpret the name as a source file. If True, the name should end with extension .curry. Otherwise the name is interpreted as a module or package name.
plan – The compilation
planThis indicates which files to consider as prerequisites. If None, a default plan
- Raises:
ModuleLookupError – the module was not found.
- Returns:
.json), Curry source file (suffix: .curry), Python file (suffix: .py), C++ source (suffix: .cpp) or object (suffix: .so), or directory. The JSON name may have an additional .z suffix. The JSON file is returned if it is up-to-date, otherwise, the Curry file is returned if it exists. If neither of those applies, the package directory name is returned, if it exists.
- Return type:
The name of an ICurry-JSON file (suffix
- curry.toolchain.curry2icurry(curryfile, currypath, **kwds)[source]
Produces an ICurry file from a Curry file.
- Parameters:
curryfile – The name of the Curry file to convert.
currypath – The list of Curry code search paths.
**kwds – Additional keywords. See
Curry2ICurryConverter.
- Returns:
The ICurry file name.
- curry.toolchain.curryfilename(filename)[source]
Gets the Curry file associated with a JSON file or ICurry file. If the input is a Curry file, it is returned.
- curry.toolchain.icurry2json(icurryfile, currypath, **kwds)[source]
Converts an ICurry file to an ICurry-JSON file.
- Parameters:
icurryfile – The name of the ICurry file to convert. A Curry file name selects its ICurry file. A JSON file is compressed or decompressed as needed.
currypath – The list of Curry code search paths. The conversion reads one file and does not use it. The compilation plan passes it to every step.
**kwds – Additional keywords. See
ICurry2JsonConverter.
- Returns:
The JSON file name. May end with .json or .json.z.
- curry.toolchain.icurryfilename(filename)[source]
Gets the ICurry file name associated with a Curry file.
- curry.toolchain.jsonfilenames(filename, suffixes=None)[source]
Gets the JSON file name(s) associated with a Curry or ICY file.
- curry.toolchain.loadcurry(plan, name, currypath=None, **kwds)[source]
Builds (if necessary) and loads the named module.
- Parameters:
plan – The compile plan.
name – The source file, module, or package name.
currypath – A sequence of paths to search (i.e., CURRYPATH split on ‘:’). By default,
curry.pathis used.is_sourcefile – If true, the name arguments is interpreted as a source file. Otherwise, it is interpreted as a module name.
- Raises:
ModuleLookupError – the module was not found.
- Returns:
A Python object containing the ICurry for the given name.
- curry.toolchain.loadjson(jsonfile)[source]
Reads an ICurry-JSON file and returns the ICurry. The file must contain one Curry module.
- curry.toolchain.makecurry(plan, name, currypath=None, **kwds)[source]
Run the build toolchain for a Curry target.
Following this, the specified file is up-to-date and can be loaded. This function uses the timestamps of prerequisite files to avoid repeating steps.
- Parameters:
plan – The build plan.
name – The module or source file name.
currypath – A sequence of paths to search (i.e., CURRYPATH split on ‘:’). By default,
curry.pathis used.is_sourcefile – If true, the name arguments is interpreted as a source file. Otherwise, it is interpreted as a module name.
**kwds – See documentation for sprite-make.
- Returns:
The name of the final file in the build pipeline.
- curry.toolchain.mergebuiltins(tgt, backend, **kwds)[source]
Merge an IModule with its built-in content.
Looks up built-in content from the backend, and, if any is found, invokes
mergemodule.- Parameters:
tgt – The module to merge content into.
backend – An instance of
IBackendused to locate built-in content.**kwds – Additional keywords passed to
mergemodule.
- curry.toolchain.mergemodule(tgt, src=None, exports=None, aliases=None, **kwds)[source]
Merge content from IModule
srcinto Imoduletgtwith the specified content.- Parameters:
tgt – The module to merge content into.
src – An instance if IModule to copy content from.
exports – A list of symbol names indicating what to copy.
exports – A list of aliases to add to add (via ‘union’) to
tgt.**kwds – Additional keywords to be passed to
mergesymbols.
Subpackages
- curry.toolchain.flat2icurry package
Flat2ICurryErrorInterfaceFinderload_flatcurry()load_interface()module_root()optimize_bindings()optimize_file()optimize_set0()product_path()read_flatcurry()rewrite_file()rewrite_prog()show_flatcurry()showhaskell()showterm()translate()translate_file()write_flatcurry()write_icurry()- Submodules
- curry.toolchain.flat2icurry.bindingopt module
- curry.toolchain.flat2icurry.casecompletion module
- curry.toolchain.flat2icurry.caselifting module
- curry.toolchain.flat2icurry.compiler module
- curry.toolchain.flat2icurry.elimnewtype module
- curry.toolchain.flat2icurry.errors module
- curry.toolchain.flat2icurry.flatcurry module
BranchCaseCaseTypeCharcCombCombTypeConsConsPartCallExprExternalFixityFloatcForallTypeFreeFuncFuncPartCallFuncTypeIntcKArrowKindLPatternLetLitLiteralNewConsOpOrPatternPatternDeclProgRuleRuleDeclTConsTVarTypeTypeDeclTypeExprTypeNewTypeSynTypedVarVisibilityall_vars()data_decls_of()decode()load()prelude()read()show()write()
- curry.toolchain.flat2icurry.icurrytypes module
- curry.toolchain.flat2icurry.interfaces module
- curry.toolchain.flat2icurry.rewrite module
- curry.toolchain.flat2icurry.setlift module
- curry.toolchain.flat2icurry.terms module