Hi Dear sirs<br><br>let's look at code<br><br><br>:- module tst2.<br><br>:- interface.<br><br>:- import_module io.<br><br>:- pred main(io, io).<br>:- mode main(di, uo) is det.<br><br>:- implementation.<br><br><br>:- import_module solutions, list, int.<br>
<br>main --><br>    {<br>     promise_equivalent_solutions [L] unsorted_solutions((pred(E::out) is nondet :-<br>                                 member(E, 1..20),<br>                                  E mod 3 = 0<br>                                 ), L)<br>
    },<br>    print(L).<br><br><br>Note, that without "promise_equivalent_solutions [L]" it gives<br><br><br>$ mmc tst2<br>tst2.m:008: In `main'(di, uo):<br>tst2.m:008:   error: determinism declaration not satisfied.<br>
tst2.m:008:   Declared `det', inferred `multi'.<br>tst2.m:017:   call to `solutions.unsorted_solutions'((pred(out) is nondet),<br>tst2.m:017:   out) can succeed more than once.<br>tst2.m:017: Error: call to predicate `solutions.unsorted_solutions'/2 with<br>
tst2.m:017:   determinism `cc_multi' occurs in a context which requires all<br>tst2.m:017:   solutions.<br><br><br>while compiling.<br><br>I've read some documentation on cc_multi, and I seem to understand the meaning of cc_multi. It's used when we defining predicate as being multi, but using it in place where we nead only 1 solution (actually, anyone.. this is determined by compiler what solution to return taking in mind optimization concerns). What I can't understand is why should I explicitely convert it to det with "promise_equivalent_solutions [L]". Why compiler is not smart enough to make this automatically? I know that I could alternatively make cc_multi my main predicate.. But what if I have some architecture with many det predicates. This would mean that I should then turn all those preds to cc_multi.. I don't like this..<br>
<br>I've also read this thread that seem to relate to my questions<br><br><a href="http://www.mercury.csse.unimelb.edu.au/mailing-lists/mercury-developers/mercury-developers.0108/0034.html">http://www.mercury.csse.unimelb.edu.au/mailing-lists/mercury-developers/mercury-developers.0108/0034.html</a><br>
<br>but still it's not very clear.<br><br>Also, it seems not very logical to me that aggregate and solutions predicates perform sorting & removing duplicates. It seems more logical that those perform as their unsorted_ counterparts and additional sorted_ versions be present.<br>
<br>I beg pardon for my, most likely, stupid questions =)<br><br>Sincerely yours,<br>Vladimir<br>