Previous: , Up: ref-mod-ilm   [Contents][Index]


4.11.13.2 Predicates Visible in a Module

The built-in predicate predicate_property/2 can be used to find the properties of any predicate that is visible to a particular module.

To backtrack through all of the predicates imported by module m, use

| ?- predicate_property(m:Goal, imported_from(_)).

To backtrack through all of the predicates imported by module m1 from module m2, use

| ?- predicate_property(m1:Goal, imported_from(m2)).

For example, you can load the between module from the library and then remind yourself of what predicates it defines like this:

| ?- compile(library(between)).
% … loading messages …

yes
| ?- predicate_property(P, imported_from(between)).
P = numlist(_A,_B) ? ;
P = numlist(_A,_B,_C,_D,_E) ? ;
  .
  .
  .

This tells you what predicates are imported into the type-in module from basics.

You can also find all imports into all modules using

| ?- predicate_property(M1:G, imported_from(M2)).

To backtrack through all of the defined predicates exported by module m, use

| ?- predicate_property(m:Goal, exported).

See mpg-ref-predicate_property.


Send feedback on this subject.