[mercury-users] Making (cc_)multi into det?

Robert Bossy bossy at ccr.jussieu.fr
Thu Aug 23 01:56:17 AEST 2001


[ Wed, 22 Aug 2001 16:57:33 +0200 (CEST) ] Ondrej Bojar <oboj7042 at ss1000.ms.mff.cuni.cz> -> <mercury-users at cs.mu.OZ.AU>

> Hi.
> 
> Is there a way to change (cc_)multi into det?
> 
> The reason to do is simple: I have a predicate, that can succeed more than
> once. But I whould like to get any of the solutions and use it in a
> predicate, that is otherwise det. And I don't want mercury to propagate
> the truth about multiple solutions further.
> 
> ...I want a "simple" solution to a complex question and I don't like to
> hear all the truth... :-)
> 
> Can I wrap the inner multi-solution predicate into something that would
> make it look like "det"?

I think that's what builtin function promise_only_solution/1 and builtin predicate promise_only_solution_io/4 are intended for.
Their interface declarations are:

:- func promise_only_solution(pred(T)) = T.
:- mode promise_only_solution(pred(out) is cc_multi) = out is det.
:- mode promise_only_solution(pred(out) is cc_nondet) = out is semidet.

:- pred promise_only_solution_io(pred(T, IO, IO), T, IO, IO).
:- mode promise_only_solution_io(pred(out, di, uo) is cc_multi,
		out, di, uo) is det.

However the Mercury Library Reference Manual says:
% Note that misuse of this predicate may lead to unsound results:
% if the assumption is not satisfied, the behaviour is undefined.
% (If you lie to the compiler, the compiler will get its revenge!)

RB
--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list