@jan - wouldn’t it make sense to turn off generate_debug_info
in library(aggregate), so that tracing behaves more like the builtin setof/bagof/findall?
Compare these:
?- trace, setof(X, a(X), Xs).
Call: (11) setof(_848, a(_848), _856) ? creep
Call: (17) a(_848) ? creep
Exit: (17) a(1) ? creep
Redo: (17) a(_848) ? creep
Exit: (17) a(2) ? creep
Redo: (17) a(_848) ? creep
Exit: (17) a(3) ? creep
Exit: (11) setof(_848, user:a(_848), [1, 2, 3]) ? creep
Xs = [1, 2, 3].
?- trace, aggregate(set(X), a(X), Xs).
Call: (11) aggregate:aggregate(set(_3064), a(_3064), _3076) ? creep
Call: (12) aggregate:template_to_pattern(bag, set(_3064), _3710, user:a(_3064), _3712, _3714) ? creep
Call: (13) aggregate:template_to_pattern(set(_3064), _3710, _3762, _3764, _3714) ? creep
Call: (14) aggregate:templ_to_pattern(set(_3064), _3710, _3762, _3764, _3714) ? creep
Exit: (14) aggregate:templ_to_pattern(set(_3064), _3064, true, [], set) ? creep
Exit: (13) aggregate:template_to_pattern(set(_3064), _3064, true, [], set) ? creep
Call: (13) aggregate:existential_vars(user:a(_3064), _3950, _3952, []) ? creep
Call: (14) var(user:a(_3064)) ? creep
Fail: (14) var(user:a(_3064)) ? creep
Redo: (13) aggregate:existential_vars(user:a(_3064), _3950, _3952, []) ? creep
Call: (14) _4144=_3952 ? creep
Exit: (14) _3952=_3952 ? creep
Call: (14) aggregate:existential_vars(a(_3064), _4142, _3952, []) ? creep
Call: (15) var(a(_3064)) ? creep
Fail: (15) var(a(_3064)) ? creep
Redo: (14) aggregate:existential_vars(a(_3064), _4142, _3952, []) ? creep
Exit: (14) aggregate:existential_vars(a(_3064), a(_3064), [], []) ? creep
Exit: (13) aggregate:existential_vars(user:a(_3064), user:a(_3064), [], []) ? creep
Call: (13) aggregate:clean_body((user:a(_3064), true), _4520) ? creep
Call: (14) aggregate:clean_body(user:a(_3064), _4568) ? creep
Exit: (14) aggregate:clean_body(user:a(_3064), user:a(_3064)) ? creep
Call: (14) aggregate:clean_body(true, _4662) ? creep
Exit: (14) aggregate:clean_body(true, true) ? creep
Call: (14) user:a(_3064)==true ? creep
Fail: (14) user:a(_3064)==true ? creep
Redo: (13) aggregate:clean_body((user:a(_3064), true), _4520) ? creep
Call: (14) true==true ? creep
Exit: (14) true==true ? creep
Call: (14) _4520=user:a(_3064) ? creep
Exit: (14) user:a(_3064)=user:a(_3064) ? creep
Exit: (13) aggregate:clean_body((user:a(_3064), true), user:a(_3064)) ? creep
Call: (13) bag==bag ? creep
Exit: (13) bag==bag ? creep
Call: (13) aggregate:add_existential_vars([], user:a(_3064), _3712) ? creep
Exit: (13) aggregate:add_existential_vars([], user:a(_3064), user:a(_3064)) ? creep
Exit: (12) aggregate:template_to_pattern(bag, set(_3064), _3064, user:a(_3064), user:a(_3064), set) ? creep
Call: (12) bagof(_3064, user:a(_3064), _5354) ? creep
Call: (18) a(_3064) ? creep
Exit: (18) a(1) ? creep
Redo: (18) a(_3064) ? creep
Exit: (18) a(2) ? creep
Redo: (18) a(_3064) ? creep
Exit: (18) a(3) ? creep
Exit: (12) bagof(_3064, user:a(_3064), [1, 2, 3]) ? creep
Call: (12) aggregate:aggregate_list(set, [1, 2, 3], _3076) ? creep
Call: (13) sort([1, 2, 3], _3076) ? creep
Exit: (13) sort([1, 2, 3], [1, 2, 3]) ? creep
Exit: (12) aggregate:aggregate_list(set, [1, 2, 3], [1, 2, 3]) ? creep
Exit: (11) aggregate:aggregate(set(_3064), user:a(_3064), [1, 2, 3]) ? creep
Xs = [1, 2, 3].