[mercury-users] Mercury Types Problem
Bob McKay
rim at cs.adfa.edu.au
Thu Jun 20 16:30:21 AEST 2002
Hi Ralph; thanks again for your help. Unfortunately, I don't think I made my
question sufficiently clear. I understand what has gone wrong, and what the
compiler messages are saying. What I _don't_ understand is what the
correct syntax is. ie we have the named type and mode declarations:
:- type eval_pred(Ind) == (pred(Ind, Ind, message, message, supply, supply)).
:- mode eval_pred == (pred(in, out, out, out, mdi, muo) is det).
Now I want to create a predicate using those named types and modes. What I
don't understand, and can't find in the manual, is how to do this. I had hoped
that perhaps the compiler might treat the equivalences as macro expansions,
but as you point out, it doesn't, seeing them in the form I used as simply
parameters, and hence of the wrong arity. I assume there is some way of doing
this (else why bother having named types and modes for predicates), but I
haven't the foggiest what it is.
Taking the type declaration first. Presumably the compiler is expecting
something of the form
:- pred eval_ind
as a flag that this is a predicate declaration. And presumably there is some
magic syntax thereafter which associates the type with the instantiated type I
want, namely eval_pred(ind). What I need to know is what that syntx is.
Similary, for the mode, the compiler is presumably expecting a mode
declaration to begin
:- mode eval_ind
And presumably there is some syntax to associate the mode with the above
declared one, ie eval_pred. Again, what I need to know is what that syntax
is. I presume it's not just
:- mode eval_ind == eval_pred.
because that would confuse predicate mode declarations and mode equivalences
(I think 8^).
Best Wishes
Bob McKay
>
> Bob McKay, Thursday, 20 June 2002:
> > Hi folks; probably a fairly trivial syntax problem this time:
> >
> > On Tuesday, May 28, 2002, at 02:01 PM, Ralph Becket wrote:
> > >Tip: it's a good idea to name complex higher order types and modes:
> > >
> > >:- type eval_pred(T) == (pred(T, T, message, message, supply, supply)).
> > >:- inst eval_pred == (pred(in, uo(individuals), out, out, mdi, muo)
> > >is det).
> >
> > I'm trying this as:
> >
> > :- type eval_pred(Ind) == (pred(Ind, Ind, message, message, supply,
> > supply)).
> > :- mode eval_pred == (pred(in, out, out, out, mdi, muo) is det).
> >
> > :- pred eval_ind(eval_pred(ind)). %1
> > :- mode eval_ind(eval_pred). %2
> >
> >
> > eval_ind(Uneval_ind, Eval_ind, Defmessage, Fitmessage, RS0, RS1) :-
> > <clause body>
> >
> > gives the error messages
> >
> > eval.m:017: Error: no determinism declaration for exported
> > eval.m:017: predicate `eval:eval_ind/1'.
>
> This says you've missed off the `is <determinism>' part of the mode
> declaration for eval_ind/1.
>
> > eval.m:026: Error: clause for predicate `eval:eval_ind/6'
> > eval.m:026: without preceding `pred' declaration.
>
> This says you've written a clause
>
> eval_ind(A, B, C, D, E, F) :- ...
>
> but you've only declared a pred with this name that takes a single
> argument:
>
> :- pred eval_ind(eval_pred(ind)).
> ^^^^^^^^^^^^^^--- one argument.
>
> > eval.m:016: Error: no clauses for predicate `eval:eval_ind/1'.
>
> and you haven't written any eval_ind/1 clauses
>
> > eval.m:026: Inferred :- pred eval_ind((rep:ind), (rep:ind),
> > (myutils:message), (
> > myutils:message), (random:supply), (random:supply)).
>
> but this is what the compiler managed to infer about the mysterious
> eval_ind/6 clause!
>
> - Ralph
> --------------------------------------------------------------------------
> 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
> --------------------------------------------------------------------------
>
--------------------------------------------------------------------------
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