diff: minor clpr changes

Fergus Henderson fjh at kryten.cs.mu.OZ.AU
Sun Sep 14 22:03:22 AEST 1997


A few minor cleanups in the CLP(R) stuff.

clpr/dump.m:
	Add a mode to dump_one_solution/3 for the case where the called
	predicate is semidet.

clpr/samples/laplace.m:
clpr/samples/sum_list.m:
	Fix determinism warnings by declaring predicates as `semidet'
	rather making them `cc_multi' just so they can be passed to
	dump_one_solution/3.

clpr/samples/laplace.m:
	Use an if-then-else rather than require/1, because the use
	of require/1 is a mode error. 
	(XXX the compiler doesn't yet detect the error.)

cvs diff clpr/dump.m clpr/samples/laplace.m clpr/samples/sum_list.m
Index: clpr/dump.m
===================================================================
RCS file: /home/mercury1/repository/clpr/dump.m,v
retrieving revision 1.9
diff -u -r1.9 dump.m
--- 1.9	1997/09/08 19:05:29
+++ dump.m	1997/09/14 11:43:35
@@ -26,9 +26,11 @@
 	%	or, Pred(CfloatList, NameList) has no solution, and IO is
 	%	obtained from IO0 by writing "No solutions.\n" to stdout.
 :- pred dump_one_solution(
-		pred(list(cfloat), list(string))::
-			pred(list_co, out) is cc_nondet,
-		io__state::di, io__state::uo) is cc_multi.
+		pred(list(cfloat), list(string)), io__state, io__state).
+:- mode dump_one_solution(
+		pred(list_co, out) is cc_nondet, di, uo) is cc_multi.
+:- mode dump_one_solution(
+		pred(list_co, out) is semidet, di, uo) is cc_multi.
 
 :- pred dump_cfloat(cfloat::ca, io__state::di, io__state::uo) is cc_multi.
 	% dump_cfloat(X, IO0, IO) is true iff
Index: clpr/samples/laplace.m
===================================================================
RCS file: /home/mercury1/repository/clpr/samples/laplace.m,v
retrieving revision 1.1
diff -u -r1.1 laplace.m
--- 1.1	1997/09/03 10:37:31
+++ laplace.m	1997/09/14 11:44:13
@@ -115,10 +115,12 @@
 	    % [100, _, _, _, _, _, _, _, _, _, 100], 
 	    % [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100]
 
-	% XXX use of `require' is a bug (should be a mode error)
-	{ require(laplace(X), "laplace failed\n") },
-	io__write_string("\n"),
-	printmat(X).
+	( { laplace(X) } ->
+		io__write_string("\n"),
+		printmat(X)
+	;
+		{ error("laplace/1 failed") }
+	).
 
 % Answer:
 %    0.00   0.00   0.00   0.00   0.00   0.00   0.00   0.00   0.00   0.00   0.00
@@ -136,11 +138,11 @@
 :- pred main2(io__state::di, io__state::uo) is cc_multi.
 main2 --> dump_one_solution(go2).
 
-:- pred go2(list(cfloat)::list_co, list(string)::out) is cc_nondet.
+:- pred go2(list(cfloat)::list_co, list(string)::out) is semidet.
 go2(		[B31,   M32,   M33,   B34,   B42,   B43,   
-		B12,   B13,   B21,   M22,   M23,   B24],
+		 B12,   B13,   B21,   M22,   M23,   B24],
      		["B31", "M32", "M33", "B34", "B42", "B43",
-     		"B12", "B13", "B21", "M22", "M23", "B24"]) :-
+     		 "B12", "B13", "B21", "M22", "M23", "B24"]) :-
 	init(B11), init(B12), init(B13), init(B14),
 	init(B21), init(M22), init(M23), init(B24),
 	init(B31), init(M32), init(M33), init(B34),
Index: clpr/samples/sum_list.m
===================================================================
RCS file: /home/mercury1/repository/clpr/samples/sum_list.m,v
retrieving revision 1.1
diff -u -r1.1 sum_list.m
--- 1.1	1997/09/03 10:37:37
+++ sum_list.m	1997/09/14 11:43:43
@@ -12,7 +12,7 @@
 
 main --> dump_one_solution(goal).
 
-:- pred goal(list(cfloat)::list_co, list(string)::out) is cc_nondet.
+:- pred goal(list(cfloat)::list_co, list(string)::out) is semidet.
 goal([Result], ["Result"]) :-
 	make_cfloat_list(40, TheList),
 	cfloat__init(Result),

-- 
Fergus Henderson <fjh at cs.mu.oz.au>   |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>   |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3         |     -- the last words of T. S. Garp.



More information about the developers mailing list