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

Terrence Brannon metaperl at pacbell.net
Fri Jul 13 11:23:15 AEST 2001


Peter Ross writes:
 : wished to achieve which is to make main return only one answer.

well that's the current goal. my plan as soon as this works is to come
up with a travel desk application. That extends this in two ways. One
is that I will iteratively return all solutons. The second is that I
will find all solutions for various numbers of border-hops. Ie,
someone calls in with a 3-border pass and wants to know their
options. Someone else wants to make 1-border trips only, etc.

 : Hope this helps.

It does, but now I have managed to create yet another very
hard-to-follow answer. This is embarrassing... perhaps I should just
chill out until the beginner book comes? I don't have to do this you
know.. I am a Perl programmer by trade. I just think this language is
interesting and has great promise. I think the time has come to quit
writing the same logic and data flows in newer and newer and trendier
languages and set down the patterns of all these computations in the
language offering such control and conciseness... and that does in
fact appear to be Mercury. And like I said before, I think that my
ignorance is indicating to the Mercury book authors just the sorts of
things they will have to cover. Anyway,

[localhost:lexparse/border/2nd-try] metaperl% mmake border.depend
mmc --generate-dependencies --grade none.gc         border
[localhost:lexparse/border/2nd-try] metaperl% mmake border
rm -f border.c
mmc --compile-to-c --grade none.gc         border.m > border.err 2>&1
gmake: *** [border.c] Error 1
[localhost:lexparse/border/2nd-try] metaperl% cat border.err
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")
	).

:- pred border(string, string).
:- mode border(in, out) is nondet.
:- mode border(out, in) is nondet.

border("sussex","kent").
border("sussex","surrey").
border("surrey","kent").
border("hampshire","sussex").
border("hampshire","surrey").
border("hampshire","berkshire").
border("berkshire","surrey").
border("wiltshire","hampshire").
border("wiltshire","berkshire").

:- pred adjacent(string, string).
:- mode adjacent(in, out) is nondet.

adjacent(X,Y) :- border(X,Y).
adjacent(X,Y) :- border(Y,X).

:- pred affordable(string, string).
:- mode affordable(in, out) is nondet.

affordable(X,Y) :- adjacent(X,Z), adjacent(Z,Y).
[localhost:lexparse/border/2nd-try] metaperl% 

--------------------------------------------------------------------------
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