10.36.4.1 Customizing Output

The printing of variable names is customized by defining the following hook predicate.

fdbg:fdvar_portray(Name, Var, FDSet) hook
This hook predicate is called whenever an annotated constraint variable (see FDBG Annotation) is printed. Name is the assigned name of the variable Var, whose domain will be FDSet as soon as the narrowings of the current constraint take effect. The current domain is not stored in this compoun, but it can be easily determined with a call to fd_set/2. (Although these two sets may be the same if the constraint didn't narrow it.)

If fdbg:fdvar_portray/3 is undefined or fails the default representation is printed, which is Name between angle brackets.

The printing of legend lines is customized by defining the following hook predicate.

fdbg:legend_portray(Name, Var, FDSet) hook
This hook is called for each line of the legend by the built-in legend printer. The arguments are the same as in the case of fdbg:fdvar_portray/3. Note that a prefix of four spaces and a closing newline character is always printed by FDBG.

If fdbg:fdvar_portray/3 is undefined or fails the default representation is printed, which is

          Name = RangeNow [ -> RangeAfter ]
     

The arrow and RangeAfter are only printed if the constraint narrowed the domain of Var.

The following example will print a list of all possible values instead of the range for each variable in the legend:

     :- multifile fdbg:legend_portray/3.
     fdbg:legend_portray(Name, Var, Set) :-
             fd_set(Var, Set0),
             fdset_to_list(Set0, L0),
             fdset_to_list(Set, L),
             (   L0 == L
             ->  format('~p = ~p', [Name, L])
             ;   format('~p = ~p -> ~p', [Name, L0, L])
             ).

Send feedback on this subject.