curry.interpreter.loadsave module

curry.interpreter.loadsave.load(interp, filename, **kwds)[source]

Loads a Curry module saved with save().

Aside from how the file is located, this follows the import protocol, so the module is added to the interpreter’s modules dict.

Parameters:
  • filename – The path to a file to load. The file type and suffix must match the interpreter.

  • from_plan – True when the import plan loads the current object of a module it imports, False for a file the user named (the C++ backend decides some refusals by it; see its loader).

Returns:

A CurryModule.

curry.interpreter.loadsave.save(cymodule, filename=None, goal=None, **kwds)[source]

Saves a Curry module.

Parameters:
  • cymodule – The argument to dump. Must be a valid argument to inspect.geticurry.

  • filename – A file name, stream, or None. If None, a string is returned. Otherwise, the file is created, if specified, and the output is written to the file or stream.

  • goal – The goal the saved program evaluates when it runs, unless -g on its command line names another. A program needs one: without goal the call raises ValueError (issue #35). To save a module without a main program, for load(), pass module_main=False. A goal with class constraints and no signature is defaulted with the table of the PAKCS REPL at run time; the file records its type, so it runs from any directory. A goal the table cannot default raises here, at save time. On the C++ backend the saved file is C++ source, and its record names the source of the module relative to the directory of the object (the product directory beside the source, .curry/<subdir>/). Compile the file in that directory, as sprite-make --so does; an object compiled elsewhere loads, but its module has no source file (backends.cxx.loader.source_file).

  • kwds – Additional keyword arguments passed to IBackend.write_module. Possibly specific to the backend.

Returns:

If filename is None, the module contents are returned as a string. Otherwise, None.