mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-15 17:33:38 +00:00
library/builtin:
Delete the promise_only_solution/1 and promise_only_solution_io/4. Both
have have been marked as obsolete since 2015.
Also delete the non-public impure versions of those, get_one_solution/1
and get_one_solution_io/4. Implementing the pure versions was the only
use of these.
compiler/hlds_goal.m:
Delete a reference to promise_only_solution in a comment.
tests/declarative_debugger/trust.exp:
tests/declarative_debugger/trust.inp:
tests/declarative_debugger/trust_1.m:
Replace a call to promise_only_solution/1; this does simplify this test
a little, but does not affect what the trust_1 module was testing, namely
the user-defined comparison on the type exported by that module.
tests/declarative_debugger/exceptions.m:
tests/hard_coded/myset.m:
tests/hard_coded/user_compare.m:
tests/valid_seq/intermod_nested_module_bug2.m:
extras/curs/samples/nibbles.m:
Replace calls to the now deleted predicates.
110 lines
2.0 KiB
Mathematica
110 lines
2.0 KiB
Mathematica
%---------------------------------------------------------------------------%
|
|
% vim: ts=4 sw=4 et ft=mercury
|
|
%---------------------------------------------------------------------------%
|
|
|
|
:- module exceptions.
|
|
|
|
:- interface.
|
|
|
|
:- import_module io.
|
|
|
|
:- pred main(io::di, io::uo) is cc_multi.
|
|
|
|
:- implementation.
|
|
|
|
:- import_module exception.
|
|
:- import_module int.
|
|
:- import_module list.
|
|
:- import_module maybe.
|
|
:- import_module univ.
|
|
|
|
main(!IO) :-
|
|
% Test finding wrong answer children with a try_all.
|
|
q(MaybeExcp, Solutions),
|
|
( if
|
|
% Test finding missing answer children with a try_all.
|
|
r(_)
|
|
then
|
|
io.write_string("yes\n", !IO)
|
|
else
|
|
io.write_string("no\n", !IO)
|
|
),
|
|
( if
|
|
% Test finding exception children when there is backtracking.
|
|
v(X)
|
|
then
|
|
io.write_int(X, !IO)
|
|
else
|
|
io.write_string("no\n", !IO)
|
|
),
|
|
io.write({MaybeExcp, Solutions}, !IO),
|
|
io.nl(!IO).
|
|
|
|
:- pred p(int::out) is multi.
|
|
|
|
p(X) :-
|
|
( X = 1
|
|
; X = 2
|
|
; X = 3
|
|
; throw("Error")
|
|
).
|
|
|
|
:- pred q(maybe(univ)::out, list(int)::out) is cc_multi.
|
|
|
|
q(MaybeExcp, Solutions) :-
|
|
try_all(p, MaybeExcp, Solutions).
|
|
|
|
:- pred r({maybe(univ), list(int)}::out) is semidet.
|
|
|
|
r(Sols) :-
|
|
% This is a lie, but is the only way I seem to be able to call try_all
|
|
% in a failing context.
|
|
promise_equivalent_solutions [Sols] (
|
|
t(Sols)
|
|
),
|
|
semidet_fail.
|
|
|
|
:- pred s(int::out) is multi.
|
|
|
|
s(X) :-
|
|
( X = 4
|
|
; X = 5
|
|
; X = 6
|
|
; throw("Error")
|
|
).
|
|
|
|
:- pred t({maybe(univ), list(int)}::out) is cc_multi.
|
|
|
|
t(S) :-
|
|
try_all(s, MaybeExcp, Solutions),
|
|
S = {MaybeExcp, Solutions}.
|
|
|
|
:- pred u(int::out) is multi.
|
|
|
|
u(X) :-
|
|
( X = 7
|
|
; X = 8
|
|
; X = 9
|
|
; throw("Error")
|
|
).
|
|
|
|
:- pred v(int::out) is nondet.
|
|
|
|
v(X) :-
|
|
y(Z),
|
|
u(Y),
|
|
x(Y),
|
|
add(Y, Z, X).
|
|
|
|
:- pred x(int::in) is semidet.
|
|
|
|
x(1).
|
|
|
|
:- pred add(int::in, int::in, int::out) is det.
|
|
|
|
add(X, Y, X + Y).
|
|
|
|
:- pred y(int::out) is det.
|
|
|
|
y(1).
|