Inspecting programs with attributed variables using clause/2

I have this code that uses library(clpBNR):

edge(T, A, B) :-
        seg(A1, B1),
        point(A,PA),
        point(B,PB),
        dist(A1, PA, T),
        dist(B1, PB, T).

dist(p(X1, Y1), p(X2, Y2), D) :-
% clpBNR constraint, X1/Y1/X2/Y2/D don't have to be ground
        { sqrt((X2 - X1)^2 + (Y2 - Y1)^2) =< D }.

seg(..., ...) % Not important, omitted for brevity
point(..., ...) 

Now, when I try to get the body of edge/3 with clause/2 I get … silent death:

122 ?- listing(edge/3).
experiment_file:edge(T, A, B) :-
    seg(A1, B1),
    point(A, PA),
    point(B, PB),
    dist(A1, PA, T),
    dist(B1, PB, T).

true.

123 ?- clause(edge(A,B,C), Bod).
false.

Is this normal? Is there an alternative to clause/2 to get the body of a clause when there are attributed variables in one of the body goals?

Try ?- clause(experiment_file:edge(A,B,C), Bod). … listing/1 uses clause/2, so it should work. It is only more flexible to find what you are trying to list. I.e., if there is no module specified try in every module.

Not relevant to your problem, but there will be no attributes attached to any of the variables in the results of listing/1 or clause/2. They don’t get defined (via side effect) until dist/3 is actually called, and ?- listing(edge/3). won’t do that.