[mercury-users] Another Mercury Modes Problem

Bob McKay bob_mckay at mac.com
Tue May 28 11:37:09 AEST 2002


I'm sorry to trouble you all with fairly trivial misunderstandings
of Mercury, but unfortunately I have hit another. I have
declared

:- type individual
         --->    individual(
                         definition,
                         maybe(fitness)
                 ).

:- inst init_individual == bound(individual(ground, bound(no))).
#:- inst individual == bound(individual(ground, bound(yes(ground)))).
:- inst init_individual_list == unique(list(init_individual)).
#:- inst individual_list == unique(list(individual)).

:- mode create_ind == free >> init_individual.
:- mode eval_ind == free >> individual.
:- mode create_ind_list == free >> init_individual_list.
#:- mode eval_ind_list == free >> individual_list.

:- pred eval_ind(individual,individual,
	message,message,supply,supply).
:- mode eval_ind(in,eval_ind,out,out,mdi,muo) is det.

:- pred eval_population(list(P),list(P),list(message),
		pred(P,P,message,message,supply,supply),
		supply,supply).
:- mode eval_population(in,eval_ind_list,out,
   in(pred(in,eval_ind,out,out,mdi,muo)is det),mdi,muo) is det.

#eval_population([],[],[],_) --> !.
#eval_population([IUneval|IUnevals],[IEval|IEvals],
   [Indmessage,Fitmessage|Messages],Process) -->
         Process(IUneval,IEval,Indmessage,Fitmessage),
         eval_population(IUnevals,IEvals,Messages,Process).

where I have marked the lines I _think_ are relevant to the problem
with #. Running this gets me the error messages:

evaluate.m:032: In clause for `eval_population(in, (rep:eval_ind_list), 
out, in(
(pred(in, (rep:eval_ind), out, out, mdi, muo) is det)), mdi, muo)':
evaluate.m:032:   mode error: argument 3 had the wrong instantiatedness.
evaluate.m:032:   Final instantiatedness of `HeadVar__2' was 
`unique(list:'.'(bound(individual(ground, bound(yes(ground)))), 
unique(list:list((rep:individual)))) ; (list:[]))',
evaluate.m:032:   expected final instantiatedness was 
`(rep:individual_list)'.

(evaluate.m:0.32 is the first line of the second rule of
eval_population; the modes are declared in module rep). I am
assuming:
.that the argument count includes the functor, so this _is_
talking about the parameter with mode ind_list
.that I am somehow misunderstanding how list interacts with modes
(ie that the declaration unique(list(individual)) is wrong), but
every alternative I have tried seems to screw up.

So your help in pointing out my misunderstanding in this instance
would be greatly appreciated
	Best Wishes
	Bob McKay


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