SWI-Prolog 5.6.59 Reference Manual: Section 5.9

## 5.9 Module Handling Predicates

This section gives the predicate definitions for the remaining built-in predicates that handle modules.

:- module(+Module, +PublicList)
  This directive can only be used as the first term of a source file. It declares the file to be a module file, defining Module and exporting the predicates of PublicList. PublicList is a list of predicate indicators (name/arity or name//arity pairs) or operator declarations using the format `op(Precedence, Type, Name)`. Operators defined in the export list are available inside the module as well as to modules importing this module. See also section 4.24.
module_transparent +Preds
  Preds is a comma separated list of name/arity pairs (like dynamic/1). Each goal associated with a transparent declared predicate will inherit the context module from its parent goal.
meta_predicate +Heads
  This predicate is defined in `library(quintus)` and provides a partial emulation of the Quintus predicate. See section 5.10.1 for details.
current_module(-Module)
  Generates all currently known modules.
current_module(?Module, ?File)
  Is true if File is the file from which Module was loaded. File is the internal canonical filename. See also source_file/[1,2].
context_module(-Module)
  Unify Module with the context module of the current goal. context_module/1 itself is transparent.
strip_module(+Term, -Module, -Plain)
  Used in module transparent or meta-predicates to extract the referenced module and plain term. If Term is a module-qualified term, i.e. of the format Module:Plain, Module and Plain are unified to these values. Otherwise Plain is unified to Term and Module to the context module.
export(+PredicateIndicator, ...)
  Add a predicate to the public list of the context module. This implies the predicate will be imported into another module if this module is imported with use_module/[1,2]. Note that predicates are normally exported using the directive module/2. export/1 is meant to handle export from dynamically created modules.
export_list(+Module, ?Exports)
  Unifies Exports with a list of predicate indicators, one for each public predicate of Module. The order of the terms in Exports is not defined. Predicate indicators are in canonical form (i.e. always using Name/Arity and never the DCG form Name//Arity). Future versions may also use the DCG form and include public operators. See also predicate_property/2.
import_module(+Module, -Import)
  True if Import is defined as an import module for Module. All normal modules only import from `user`, which imports from `system`. The predicates add_import_module/3 and delete_import_module/2 can be used to manipulate the import list.
add_import_module(+Module, +Import, +StartOrEnd)
  If Import is not already an import module for Module, add it to this list at the `start` or `end` depending on StartOrEnd. See also import_module/2 and delete_import_module/2.
delete_import_module(+Module, +Import)
  Delete Import from the list of import modules for Module. Fails silently if Import is not in the list.
default_module(+Module, -Default)
  Successively unifies Default with the module names from which a call in Module attempts to use the definition. For the module `user`, this will generate `user` and `system`. For any other module, this will generate the module itself, followed by `user` and `system`.

  Backward compatibility. New code should use import_module/2.

module(+Module)
  The call `module(Module)` may be used to switch the default working module for the interactive top-level (see prolog/0). This may be used to when debugging a module. The example below lists the clauses of file_of_label/2 in the module `tex`.

      1 ?- module(tex).

      Yes
      tex: 2 ?- listing(file_of_label/2).
      ...