[mercury-users] Mercury Types Problem

Simon Taylor stayl at cs.mu.OZ.AU
Thu Jun 20 16:42:29 AEST 2002

On 20-Jun-2002, Bob McKay <rim at cs.adfa.edu.au> wrote:
> 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^).

Recent versions of the compiler allow

:- pred eval_ind `with_type` eval_pred(Ind).
:- mode eval_ind `with_inst` eval_pred.

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