4 SICStus Prolog library
4.1 Install and get started
You can download the library at the follwing location:
http://contraintes.inria.fr/~coquery/tclp/download.en.html
Just extract the archive where who want the library to be installed.
To install the library as a SICStus Prolog library, extract it to a
temporary folder and copy the files in the directory tclp-xxx to
the SICStus Prolog library directory (e.g. /usr/local/lib/sicstus-3.9.1/library).
The library can be loaded with the use_module directive:
- :- use_module('tclp-installation-directory/tclp')
- or :- use_module(library(tclp)) if the TCLP library is
installed into the SICStus Prolog library directory.
Then you must choose the prolog dialect of the files to type check,
using one of the following predicates:
-
iso/0: the initializes TCLP for ISO dialect
- gnu/0: the initializes TCLP for GNU Prolog dialect
- sicstus/0: the initializes TCLP for SICStus Prolog dialect
You can type check files and load types using the tclp/1
predicate:
- :- tclp('file1.typ').
- :- tclp(['file2.typ', 'file3.pl']).
- ...
4.2 Available predicates
These predicate are available in the TCLP library
4.2.1 Type initialization
-
tclp__reinit
- Remove all types from the current type data
base and reload the types corresponding to the current dialect,
using tclp__reinit/1 and user:init_dialect/1.
- tclp__reinit(+Goal)
- Remove all types from the current
type data base, executes Goal and real the standard library
according to the current settings (usually, Goal is used to
determine these settings).
- tclp__set_dialect(+Dialect)
- Sets the current CLP
dialect to Dialect.
- user:init_dialect(+Dialect)
- This is a dynamic
predicate used by tclp__reinit/0.
- sicstus
- Sets the dialect to SICStus Prolog and reinits the types.
- iso
- Sets the dialect to ISO Prolog and reinits the types.
- gnu
- Sets the dialect to GNU Prolog and reinits the types.
4.2.2 Processing
-
tclp(+FileOrFiles)
- FileOrFiles is either on
file name or a list of file names. TCLP first loads '.typ'
files of FileOrFiles, then reads and type checks '.pl' files of FileOrFiles.
- tclp__process_typ(+FileOrFiles)
- FileOrFiles
is a file or a list files. TCLP loads TCLP declarations in these files.
- tclp__process_pl(+FileOrFiles)
- FileOrFiles
is a file or a list files. TCLP reads Prolog programs in these files and
type check them.
- tclp__process_phrases(+PhraseList)
- PhraseList
is a list of pairs Phrase-Location, where Phrase is a phrase to type check and Location is some
information about the phrase, given by
tclp__reader:read_one_term(Stream, Phrase, Location, FileName).
-
tclp__set_inference(+TrueFalse)
- TrueFalse is
either true or false. This predicate en(dis)ables type
predicate inference in TCLP.
- tclp__add_search_directory(+Directory)
- Directory is a directory name. This predicate adds Directory to the directories used by TCLP for file lookup.
- tclp__set_stdlib_name(+File)
- Sets the name of the file
to load as the standard type library to File.
- tclp__enable_verbose(+Sort)
- Enables verbose mode for Sort, where Sort can be one of:
-
actions: prints the different actions of TCLP , like,
e.g., loading a type library.
- timing: prints CPU time used by TCLP for different actions.
- defaults: output a message each time TCLP encounters a
term that has no defined type. This can be useful to understand
some error messages.
- types: prints the type of each infered predicate (this
is activated by default)
- tclp__disable_verbose(+Sort)
- Disables verbose mode for
Sort, where Sort can take the values above.
4.2.4 The tclp() path alias
The loading of the tclp module will cause a path alias 'tclp' to be created. This alias can used, either to load a module
of the TCLP implementation (like tclp(tclp__reader)) or to
access the type files for ISO (resp. GNU and SICStus) Prolog using
tclp('lib/ISO/file.typ') (resp. tclp('lib/gprolog/file.typ') and tclp('lib/sicstus/file.typ').