[m-rev.] diff: delete obsolete all-solutions preds. from main branch std_util
Julien Fischer
juliensf at cs.mu.OZ.AU
Mon Apr 3 17:18:34 AEST 2006
Estimated hours taken: 0.1
Branches: main
Delete the obsolete versions of the all-solutions predicates from std_util.m.
(Normally we would wait until after the 0.13 release, but we don't want them
in the next g12 release of Mercury which is why they are being deleted now.)
Document some parts of the library that are handled as special cases by the
compiler and the declarative debugger.
library/std_util.m:
Delete the obsolete versions of the all-solutions predicates from
this module.
library/solutions.m:
Mention that these predicates are handled as a special case
in browser/declarative_tree.m:
Reformat a descriptive comment so that the library reference manual
doesn't have a line that exceeds 80 characters in length.
library/builtin.m:
Mention that cc_multi_equal is handled as a special case in
browser/declarative_tree.m.
Mention that dynamic_cast/2 is handled as a special case in
compiler/const_prop.m.
Julien.
Index: library/builtin.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/builtin.m,v
retrieving revision 1.119
diff -u -r1.119 builtin.m
--- library/builtin.m 29 Mar 2006 08:07:42 -0000 1.119
+++ library/builtin.m 3 Apr 2006 07:11:29 -0000
@@ -430,6 +430,9 @@
%-----------------------------------------------------------------------------%
+% NOTE: dynamic_cast/2 is handled specially compiler/const_prop.m.
+% Any changes here may need to be reflected here.
+
dynamic_cast(X, Y) :-
private_builtin.typed_unify(X, Y).
@@ -1052,6 +1055,9 @@
% cc_multi_equal
%
+% NOTE: cc_multi_equal/2 is handled specially in browser/declarative_tree.m.
+% Any changes here may need to be reflected there.
+
:- pragma foreign_proc("C",
cc_multi_equal(X::in, Y::out),
[will_not_call_mercury, thread_safe, promise_pure],
Index: library/solutions.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/solutions.m,v
retrieving revision 1.2
diff -u -r1.2 solutions.m
--- library/solutions.m 29 Mar 2006 01:35:19 -0000 1.2
+++ library/solutions.m 3 Apr 2006 07:05:48 -0000
@@ -25,9 +25,9 @@
% solutions/2 collects all the solutions to a predicate and returns
% them as a list in sorted order, with duplicates removed.
% solutions_set/2 returns them as a set. unsorted_solutions/2 returns
- % them as an unsorted list with possible duplicates; since there are an
- % infinite number of such lists, this must be called from a context in
- % which only a single solution is required.
+ % them as an unsorted list with possible duplicates; since there are
+ % an infinite number of such lists, this must be called from a context
+ % in which only a single solution is required.
%
:- pred solutions(pred(T), list(T)).
:- mode solutions(pred(out) is multi, out(non_empty_list)) is det.
@@ -170,6 +170,12 @@
%-----------------------------------------------------------------------------%
+% NOTE: the all-solutions predicates are handled specially in
+% browser/declarative_tree.m. Any changes here may need to be reflected
+% there.
+
+%-----------------------------------------------------------------------------%
+
solutions(Pred, List) :-
builtin_solutions(Pred, UnsortedList),
list.sort_and_remove_dups(UnsortedList, List).
Index: library/std_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/std_util.m,v
retrieving revision 1.310
diff -u -r1.310 std_util.m
--- library/std_util.m 29 Mar 2006 08:07:46 -0000 1.310
+++ library/std_util.m 3 Apr 2006 06:16:14 -0000
@@ -34,11 +34,8 @@
:- module std_util.
:- interface.
-:- import_module bool.
:- import_module int.
-:- import_module list.
:- import_module maybe.
-:- import_module set.
%-----------------------------------------------------------------------------%
%
@@ -91,172 +88,9 @@
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
-%
-% All-solutions predicates
-%
-
-% NOTE: the procedures in this section are all obsolete and will be deleted
-% in a later release. New code should use the versions defined in
-% solutions.m instead.
-
- % solutions/2 collects all the solutions to a predicate and returns
- % them as a list in sorted order, with duplicates removed.
- % solutions_set/2 returns them as a set. unsorted_solutions/2 returns
- % them as an unsorted list with possible duplicates; since there are an
- % infinite number of such lists, this must be called from a context in
- % which only a single solution is required.
- %
-:- pragma obsolete(solutions/2).
-:- pred solutions(pred(T), list(T)).
-:- mode solutions(pred(out) is multi, out(non_empty_list)) is det.
-:- mode solutions(pred(out) is nondet, out) is det.
-
-:- pragma obsolete(solutions/1).
-:- func solutions(pred(T)) = list(T).
-:- mode solutions(pred(out) is multi) = out(non_empty_list) is det.
-:- mode solutions(pred(out) is nondet) = out is det.
-
-:- pragma obsolete(solutions_set/2).
-:- pred solutions_set(pred(T), set(T)).
-:- mode solutions_set(pred(out) is multi, out) is det.
-:- mode solutions_set(pred(out) is nondet, out) is det.
-
-:- pragma obsolete(solutions_set/1).
-:- func solutions_set(pred(T)) = set(T).
-:- mode solutions_set(pred(out) is multi) = out is det.
-:- mode solutions_set(pred(out) is nondet) = out is det.
-
-:- pragma obsolete(unsorted_solutions/2).
-:- pred unsorted_solutions(pred(T), list(T)).
-:- mode unsorted_solutions(pred(out) is multi, out(non_empty_list))
- is cc_multi.
-:- mode unsorted_solutions(pred(out) is nondet, out) is cc_multi.
-
-:- pragma obsolete(aggregate/3).
-:- func aggregate(pred(T), func(T, U) = U, U) = U.
-:- mode aggregate(pred(out) is multi, func(in, in) = out is det, in)
- = out is det.
-:- mode aggregate(pred(out) is nondet, func(in, in) = out is det, in)
- = out is det.
-
-%-----------------------------------------------------------------------------%
-
- % aggregate/4 generates all the solutions to a predicate,
- % sorts them and removes duplicates, then applies an accumulator
- % predicate to each solution in turn:
- %
- % aggregate(Generator, Accumulator, Acc0, Acc) <=>
- % solutions(Generator, Solutions),
- % list.foldl(Accumulator, Solutions, Acc0, Acc).
- %
-:- pragma obsolete(aggregate/4).
-:- pred aggregate(pred(T), pred(T, U, U), U, U).
-:- mode aggregate(pred(out) is multi, pred(in, in, out) is det,
- in, out) is det.
-:- mode aggregate(pred(out) is multi, pred(in, di, uo) is det,
- di, uo) is det.
-:- mode aggregate(pred(out) is nondet, pred(in, di, uo) is det,
- di, uo) is det.
-:- mode aggregate(pred(out) is nondet, pred(in, in, out) is det,
- in, out) is det.
-
- % aggregate2/6 generates all the solutions to a predicate,
- % sorts them and removes duplicates, then applies an accumulator
- % predicate to each solution in turn:
- %
- % aggregate2(Generator, Accumulator, AccA0, AccA, AccB0, AccB) <=>
- % solutions(Generator, Solutions),
- % list.foldl2(Accumulator, Solutions, AccA0, AccA, AccB0, AccB).
- %
-:- pragma obsolete(aggregate2/6).
-:- pred aggregate2(pred(T), pred(T, U, U, V, V), U, U, V, V).
-:- mode aggregate2(pred(out) is multi, pred(in, in, out, in, out) is det,
- in, out, in, out) is det.
-:- mode aggregate2(pred(out) is multi, pred(in, in, out, di, uo) is det,
- in, out, di, uo) is det.
-:- mode aggregate2(pred(out) is nondet, pred(in, in, out, di, uo) is det,
- in, out, di, uo) is det.
-:- mode aggregate2(pred(out) is nondet, pred(in, in, out, in, out) is det,
- in, out, in, out) is det.
-
- % unsorted_aggregate/4 generates all the solutions to a predicate
- % and applies an accumulator predicate to each solution in turn.
- % Declaratively, the specification is as follows:
- %
- % unsorted_aggregate(Generator, Accumulator, Acc0, Acc) <=>
- % unsorted_solutions(Generator, Solutions),
- % list.foldl(Accumulator, Solutions, Acc0, Acc).
- %
- % Operationally, however, unsorted_aggregate/4 will call the
- % Accumulator for each solution as it is obtained, rather than
- % first building a list of all the solutions.
- %
-:- pragma obsolete(unsorted_aggregate/4).
-:- pred unsorted_aggregate(pred(T), pred(T, U, U), U, U).
-:- mode unsorted_aggregate(pred(out) is multi, pred(in, in, out) is det,
- in, out) is cc_multi.
-:- mode unsorted_aggregate(pred(out) is multi, pred(in, in, out) is cc_multi,
- in, out) is cc_multi.
-:- mode unsorted_aggregate(pred(out) is multi, pred(in, di, uo) is det,
- di, uo) is cc_multi.
-:- mode unsorted_aggregate(pred(out) is multi, pred(in, di, uo) is cc_multi,
- di, uo) is cc_multi.
-:- mode unsorted_aggregate(pred(muo) is multi, pred(mdi, di, uo) is det,
- di, uo) is cc_multi.
-:- mode unsorted_aggregate(pred(out) is nondet, pred(in, di, uo) is det,
- di, uo) is cc_multi.
-:- mode unsorted_aggregate(pred(out) is nondet, pred(in, di, uo) is cc_multi,
- di, uo) is cc_multi.
-:- mode unsorted_aggregate(pred(out) is nondet, pred(in, in, out) is det,
- in, out) is cc_multi.
-:- mode unsorted_aggregate(pred(out) is nondet, pred(in, in, out) is cc_multi,
- in, out) is cc_multi.
-:- mode unsorted_aggregate(pred(muo) is nondet, pred(mdi, di, uo) is det,
- di, uo) is cc_multi.
-
- % This is a generalization of unsorted_aggregate which allows the
- % iteration to stop before all solutions have been found.
- % Declaratively, the specification is as follows:
- %
- % do_while(Generator, Filter, !Acc) :-
- % unsorted_solutions(Generator, Solutions),
- % do_while_2(Solutions, Filter, !Acc).
- %
- % do_while_2([], _, !Acc).
- % do_while_2([X | Xs], Filter, !Acc) :-
- % Filter(X, More, !Acc),
- % ( More = yes ->
- % do_while_2(Xs, Filter, !Acc)
- % ;
- % true
- % ).
- %
- % Operationally, however, do_while/4 will call the Filter
- % predicate for each solution as it is obtained, rather than
- % first building a list of all the solutions.
- %
-:- pragma obsolete(do_while/4).
-:- pred do_while(pred(T), pred(T, bool, T2, T2), T2, T2).
-:- mode do_while(pred(out) is multi, pred(in, out, in, out) is det, in, out)
- is cc_multi.
-:- mode do_while(pred(out) is multi, pred(in, out, di, uo) is det, di, uo)
- is cc_multi.
-:- mode do_while(pred(out) is multi, pred(in, out, di, uo) is cc_multi, di, uo)
- is cc_multi.
-:- mode do_while(pred(out) is nondet, pred(in, out, in, out) is det, in, out)
- is cc_multi.
-:- mode do_while(pred(out) is nondet, pred(in, out, di, uo) is det, di, uo)
- is cc_multi.
-:- mode do_while(pred(out) is nondet, pred(in, out, di, uo) is cc_multi, di, uo)
- is cc_multi.
-
-%-----------------------------------------------------------------------------%
-%-----------------------------------------------------------------------------%
:- implementation.
-:- use_module solutions.
-
%-----------------------------------------------------------------------------%
maybe_pred(Pred, X, Y) :-
@@ -280,37 +114,4 @@
id(X) = X.
%-----------------------------------------------------------------------------%
-%----------------------------------------------------------------------------%
-
-% NOTE: the implementations for these predicates is in solutions.m.
-
-solutions(Pred, List) :-
- solutions.solutions(Pred, List).
-
-solutions_set(Pred, Set) :-
- solutions.solutions_set(Pred, Set).
-
-unsorted_solutions(Pred, List) :-
- solutions.unsorted_solutions(Pred, List).
-
-aggregate(Generator, Accumulator, !Acc) :-
- solutions.aggregate(Generator, Accumulator, !Acc).
-
-aggregate2(Generator, Accumulator, !Acc1, !Acc2) :-
- solutions.aggregate2(Generator, Accumulator, !Acc1, !Acc2).
-
-unsorted_aggregate(Generator, Accumulator, !Acc) :-
- solutions.unsorted_aggregate(Generator, Accumulator, !Acc).
-
-do_while(GeneratorPred, CollectorPred, Accumulator0, Accumulator) :-
- solutions.do_while(GeneratorPred, CollectorPred,
- Accumulator0, Accumulator).
-
-solutions(P) = solutions.solutions(P).
-
-solutions_set(P) = solutions.solutions_set(P).
-
-aggregate(P, F, Acc0) = solutions.aggregate(P, F, Acc0).
-
-%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list