[mercury-users] determinism not satisfied

David Overton dmo at cs.mu.OZ.AU
Wed Jul 11 23:50:26 AEST 2001


On Wed, Jul 11, 2001 at 02:05:26AM -0700, Ralph Becket wrote:
> > From: Terrence Brannon [mailto:tmbranno at oracle.com]
> > Sent: 11 July 2001 09:34
> > 
> > If anyone could help me get this simple program to work, I would
> > appreciate it. Program and compilation error messages follow.
> > 
> > % p.14 "Clause and Effect" by William Clocksin
> > 
> > :- module border.
> > :- interface.
> > :- import_module io.
> > 
> > :- pred main(io__state::di, io__state::uo) is det.
> > 
> > :- implementation.
> > :- import_module std_util.
> > 
> > main -->
> > 	{ border("sussex",L) }, io__write_string(L).
> > 
> > border("sussex","kent").
> > border("sussex","surrey").
> > 
> > adjacent(X,Y) :- border(X,Y).
> > adjacent(X,Y) :- border(Y,X).
> > 
> > affordable(X,Y) :- adjacent(X,Z), adjacent(Z,Y).
> 
> You haven't supplied type or mode declarations for these predicates.
> 
> > [localhost:mercury/lexparse/border] metaperl% mmc --infer-all border.m
> > border.m:015: Inferred :- pred border(string, string).
> > border.m:018: Inferred :- pred adjacent(string, string).
> > border.m:021: Inferred :- pred affordable(string, string).
> 
> So the compiler has inferred their types for you.
> 
> > border.m:007: In `main(di, uo)':
> > border.m:007:   error: determinism declaration not satisfied.
> > border.m:007:   Declared `det', inferred `nondet'.
> > border.m:013:   call to `border(di, uo)' can fail.
> > border.m:013:   call to `border(di, uo)' can succeed more than once.
> 
> And it looks like it's had a go at inferring modes, too, although
> these look a bit strange to me.

These aren't strange.  They are just more precise than the mode you
would probably declare if you were writing the declaration yourself.
You would probably write ':- mode border(in, out)', but the mode
analyser can infer that 'border/2' is always called with the first
argument unique (i.e. the constant "sussex") and that the second
argument is always unique when the procedure exits, so it infers the
more precise mode 'border(di, uo)'.



David
-- 
David Overton      Department of Computer Science & Software Engineering
PhD Student        The University of Melbourne, Victoria 3010, Australia
+61 3 8344 9159    http://www.cs.mu.oz.au/~dmo
--------------------------------------------------------------------------
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