[mercury-users] Mercury Modes Problem
Bob McKay
bob_mckay at mac.com
Fri May 24 13:03:03 AEST 2002
Hello all. I'm having problems with mercury modes for higher order
types, been beating my head against a brick wall for a while. Can
anyone see what is wrong with the following code (intended as a
skeleton for random initialisation of an evolutionary computation
genotype, where the actual initialisation predicate will be passed
in when the specific ec algorithm is chosen):
:- module initiate.
%=========================================================================
======
:- interface.
:- import_module random, list, int.
:- pred init_population(int,pred(P,supply,supply),list(P),
supply,supply).
:- mode init_population(in,in,out,di,uo) is det.
%=========================================================================
======
:- implementation.
:- import_module list, int.
init_population(N,Process,L) -->
({ N =< 0 }
-> { L = [] }
; (Process(I),
init_population(N - 1,Process,Is),
{ L = [I|Is] } ) ).
initiate.m:029: In clause for `init_population(in, in, out, di, uo)':
initiate.m:029: in argument 1 (i.e. the predicate term) of
higher-order predicate call:
initiate.m:029: mode error: variable `Process' has instantiatedness
`ground',
initiate.m:029: expecting higher-order pred inst (of arity 3).
For more information, try recompiling with `-E'.
(the errors with -E seem even more incomprehensible).
On a related note, both the reference manual and the library
make the statement that
"These two modes are enough for most functions and predicates.
Nevertheless, Mercury's mode system is sufficiently expressive to handle
more complex data-flow patterns, including those involving partially
instantiated data structures. (The current implementation does not
handle partially instantiated data structures yet.)"
Does this mean what it seems to - that I can't take in a partially
instantiated data structure, instantiate it further, and pass it
out? Or am I misunderstanding something here?
Thanks
Bob McKay
Signature: I am using this email account for efficiency reasons while
travelling. It is not my primary account. Please send replies for
preference to rim at cs.adfa.edu.au (mac mail does not appear to have a
mechanism to set the reply-to field)
--------------------------------------------------------------------------
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