contents index next

9. hdrug_call_tree: Displaying Lexical Hierarchies

This library is intended to be used to display lexical hierarchies in tree format. The relevant predicates all take a unary predicate Pred. The predicates then pretty print in a tree format the hierarchy related to the predicate Fuctor/1 as follows. Pred dominates all predicates that call Pred in their body.

If the optional Functor argument is absent, then the user:call_default/1 hook predicate is used to obtain Functor.

transitive(X) :- verb(X).
verb(X) :- lex(X).
noun(X) :- lex(X).

gives the tree: lex(verb(transitive),noun)

Other calls in the body are attached to the label, as a poor man's way to illustrate multiple inheritance:

transitive(X) :- verb(X).
verb(X) :- lex(X).
noun(X) :- lex(X),other(X).

gives: lex(verb(transitive),noun[other])

Leaves of the tree can be defined by the user (e.g. to stop the tree at interesting point, and to give interesting info in the label, use the hook predicate user:call_leaf(Call,Label). And yes, don't forget the obvious: it is assumed that the predicates are not recursive.

9.1. Hook Predicates

This section lists the hook predicates for the hdrug_call_tree library.

9.1.1. user:call_default(Functor)

Indicates that Functor is the default predicate for the various call_tree predicates.

9.1.2. user:call_clause(Head,Body)

9.1.3. user:call_leaf(Leaf)

9.1.4. user:call_build_lab(F,Fs,L)

9.1.5. user:call_ignore_clause(F/A)

9.2. Predicates

This section lists the predicates exported by the hdrug_call_tree library.

9.2.1. hdrug_call_tree:call_tree_bu[_tk/_clig/_latex][(Functor)]

pretty prints in a tree format the hierarchy related to the predicate Fuctor/1. If the optional Functor argument is absent, then the user:call_default/1 hook predicate is used to obtain Functor. The _tk _clig and _latex suffices indicate that a different output medium should be chosen (instead of the console).

contents index next