[mercury-users] Simple problem with switch

Renaud Paquay rpa at miscrit.be
Sat Sep 23 02:16:04 AEDT 2000


With the following simple source code, I get these errors:

ex_worksheet_parse.m:085: In `tata(in, out)':
ex_worksheet_parse.m:085:   error: determinism declaration not satisfied.
ex_worksheet_parse.m:085:   Declared `det', inferred `nondet'.
ex_worksheet_parse.m:090:   The switch on T does not cover
ex_worksheet_parse:a/0 and/or ex_worksheet_parse:b/0.
ex_worksheet_parse.m:088:   The switch on T does not cover
ex_worksheet_parse:c/0 and/or ex_worksheet_parse:d/0.
ex_worksheet_parse.m:090:   Disjunction has multiple clauses with solutions.


Why does "tutu/1" compile and not "tata/2"?

As in tata/2, I often need to apply the same predicates on different 
subsets of a enumerated type, but I never managed to make
it compile without explicitely extending the switch on one level,
thus repeating the same code for different values.

Has anybody a simple practical solution to this, wihtout
using if-then-else, neither intermediate predicate(s)?


Renaud Paquay
Mission Critical


:- type toto ---> a; b; c; d.

:- pred tutu(toto::in) is det.
tutu(T):-
	(
		(T = a; T = b), 
		true
	 ;
		T = c,
		true
	 ;
		T = d, 
		true
	).

:- pred tata(toto::in, int::out) is det.
tata(T, I):-
	(
		(T = a; T = b), 
		I = 0
	 ;
		T = c,
		I = 1
	 ;
		T = d, 
		I = 2
	).
--------------------------------------------------------------------------
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