[mercury-users] mode error: variable `DCG_0' has instantiatedness `mostly_unique'

Thomas Conway conway at cs.mu.OZ.AU
Fri Jul 13 11:55:03 AEST 2001


On Fri, Jul 13, 2001 at 11:23:15AM EST, Terrence Brannon wrote:
> border.m:013: In clause for `main(di, uo)':
> border.m:013:   in argument 2 of call to predicate `io:write_string/3':
> border.m:013:   mode error: variable `DCG_0' has instantiatedness `mostly_unique',
> border.m:013:   expected instantiatedness was `unique'.
> For more information, try recompiling with `-E'.
> [localhost:lexparse/border/2nd-try] metaperl% cat border.m
> % p.14 "Clause and Effect" by William Clocksin
> 
> :- module border.
> :- interface.
> :- import_module io.
> 
> :- pred main(io__state::di, io__state::uo) is cc_multi.
> 
> :- implementation.
> :- import_module std_util.
> 
> main -->
> 	( { border("sussex",L) }, io__write_string(L)
> 	   ;
> 	  io__write_string("Nothing borders sussex")
> 	).
> 

The two branches of this disjunction are not mutually exclusive.
The compiler could choose either disjunct and throw the other away,
except that the first one could fail. If I was the compiler, I'd
just throw away the first disjunct altogether and just keep the
second one. It would result in a program that is more or less
correct wrt the source. :-)
If-then-else will help you here. Unlike if-then-else in Prolog,
Mercury if-then-else only prunes away one of the branches of the
if-then-else, not solutions from the condition.
Try:

main -->
	( { border("sussex", L) } ->
		io__write_string(L)
	;
		io__write_string("Nothing borders sussex")
	).

The meaning of this is quite simple - if you think about it in
terms of the logic (not actual) expansion of if-then-else:

main -->
	(
		{ border("sussex", L) },
		io__write_string(L)
	;
		{ not border("sussex", L) },
		io__write_string("Nothing borders sussex")
	).

-- 
  Thomas Conway )O+
 <conway at cs.mu.oz.au>       499 User error! Replace user, and press any key.
--------------------------------------------------------------------------
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