TYPICAL / Guided Tour / Type 
Bottom 

Predicate declaration

The type system of TYPICAL allows predicate declarations with IMAGE: Predicate declarations
IMAGE: append_old

% declaration of append/3 as used in many conventional type systems
:- pred append_old(list(T), list(T), list(T)).
% implicitly converted to :- pred append_old(list(@T1), list(@T2), list(@T3)) with T1=<T, T2=<T, T3=<T.
IMAGE: append

% new, more precise declaration, using anchored type parameters and type constraints
:- pred append (list(T), list(T), list(@T)).
% :- pred append (list(@T1), list(@T2), list(@T3)) with T1=<T3, T2=<T3.

Kinds of declarations

Keyword Examples
pred declaration of a predicate with the genericity condition imposed
predl declaration of a predicate without the genericity condition meta_sort.pl
pred_neg declaration of a negatively defined predicate overlap.pl
:- pred_neg disjoint(list(@S),list(@T)) with U=<S, U=<T.
rule simplified declaration of a DCG grammar rule dcg.pl

Definitional genericity condition

If the declaration of a predicate contains type parameters, the defining clauses of that predicate must be type-consistent for all instances of the type parameters.

Example:

:- pred member(@S, list(@T)) with S=<T.  % S, T are the type parameters
member(1, [1,2]).                        % only (weakly) type-consistent
member(X, [X | L]).                      % generically type-consistent
member(X, [Y | L]) :- member(X, L).      % generically type-consistent
Top 
PREV: Type definition
NEXT: Predicate declaration examples

TYPICAL / Guided Tour / Type