[mercury-users] Mercury Types Problem
Ralph Becket
rafe at cs.mu.OZ.AU
Thu Jun 20 16:53:25 AEST 2002
Bob McKay, Thursday, 20 June 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.
> > :- pred eval_ind(eval_pred(ind)). %1
> > :- mode eval_ind(eval_pred). %2
The problem here is that the second line should read
:- mode eval_ind(eval_pred) is <determinism>.
You've omitted the last part from the declaration.
> 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.
They *are* equivalent and you can think of them pretty much as macros.
However, the type synonym names a single type and the inst declaration
applies to just one value at a time.
I *think* what you want is some way of writing something like %1 and %2
above that would mean the version with six arguments etc.
There was a suggestion (I don't recall whether it has been implemented
yet, I don't remember seeing it documented...) whereby one could do the
following:
:- 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 `with_type` eval_pred(ind).
:- mode eval_ind `with_mode` eval_pred.
which would be equivalent to writing
:- pred eval_ind(ind, ind, message, message, supply, supply).
:- mode eval_ind(in, out, out, out, mdi, muo) is det
which is what (I think) you want.
However, for now (I believe) you have to list each parameter explicitly
in a pred and mode declaration.
- 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
--------------------------------------------------------------------------
More information about the users
mailing list