Besides predicates for the defined constraints, the CHR compiler generates some support predicates in the module containing the handler. To avoid naming conflicts, the following predicates must not be defined or referred to by user code in the same module:
verify_attributes/3
attribute_goal/2
attach_increment/2
'attach_
F/A'/2
'
F/A_N_M_...'/
Arity
For the prime number example that is:
attach_increment/2 attach_prime/1/2 attach_primes/1/2 attribute_goal/2 goal_expansion/3 prime/1 prime/1_1/2 prime/1_1_0/3 prime/1_2/2 primes/1 primes/1_1/2 verify_attributes/3
If an author of a handler wants to avoid naming conflicts with the code
that uses the handler, it is easy to encapsulate the handler. The
module declaration below puts the handler into module
primes
, which exports only selected predicates--the
constraints in our example.
:- module(primes, [primes/1,prime/1]). :- use_module(library(chr)). handler eratosthenes. constraints primes/1,prime/1. ...