fcall/N makes it possible to type annotate meta calls.
prolog_meta is a TYPICAL library file containing commonly used type
definitions and predicate declarations for meta-programming.
File prolog_meta_short (only fcall/N predicates)
Output of type checking (prolog_meta.tap)
sort/3 takes in first argument the sort algorithm.
bubblesort/3 takes in first argument the sorting order.
This example illustrates the genericity condition (predicate declaration with pred or with predl).
File meta_sort
Output of prolog (meta_sort.prolog)
Output of type checking (meta_sort.tap)
:- pred map(meta(trmName(@T1,@T2) of mpred)), list(T1),list(T2)).
:- pred filter(meta(trmName(@T) of mpred)), list(T), list(T)).
File meta_map_filter
Output of prolog (meta_map_filter.prolog)
Output of type checking (meta_map_filter.tap)
foldl(Op,B,[E1,E2,...,En], ((...(B Op E1) Op E2)...) Op En))
The declaration
:- pred foldl(meta((trmName(@T1,@T,@T1) of mpred)), T1, list(T), @T2)
with T1=<T2.
is identical with the declaration
:- pred foldl(meta((trmName(@T1,@T,@T1) of mpred)), @T1n, list(@Tn), @T2)
with T1n=<T1, Tn=<T, T1=<T2.
The target type of the first operation must be the same as the type of its first argument. The operation must be able to work with every element of the list in its second argument.
File meta_foldl
Output of Prolog (meta_foldl.prolog)
Output of type checking (meta_foldl.tap)
foldr(op,b,[e1,e2,...,en], (e1 op (e2 op (...(en op b)...)))) | (foldr/4) |
foldl(op,b,[e1,e2,...,en] ((...((b op e1) op e2)...) op en)) | (foldl/4) |
compose(f,g,x, f(g(x))) | (compose/4) |
converse(f,x,y, f(y,x)) | (converse/4) |
:- pred foldr(meta((trmName(@T,@T1,@T1) of mpred)), T1,list(T),@T2)
with T1=<T2.
:- pred foldl(meta((trmName(@T1,@T,@T1) of mpred)), T1,list(T),@T2)
with T1=<T2.
:- pred compose(meta((trmName(@T2,@T3) of mpred)),
meta((trmName(@T1,T2) of mpred)), T1,T3).
:- pred converse(meta(trmName(@T1,@T2,@T3) of mpred)), T2,T1,T3).
File meta_foldr_foldl
Output of Prolog (meta_foldr_foldl.prolog)
Output of type checking (meta_foldr_foldl.tap)
Recursively computing plus/3 and times/3 with natural numbers written
in a successor notation.
For example: number 4 is written as "s(s(s(s(0))))."
File meta_fold_s
Output of Prolog (meta_fold_s.prolog)
Output of type checking (meta_fold_s.tap)
Application of meta-type meta((trmFull of mclause)).
Some wrong typings of assert/1 are shown.
:- pred assert(meta((trmFull of mclause))),
:- retract(meta((trmFull of mclause))),
:- retractall(meta((trmFull of mpred))).
File meta_assert
Output of type checking (meta_assert.tap)
PREV: Syntax of meta-type |
NEXT: Module system |