[mercury-users] no clauses for predicate, mistaken higher-order predicate call
Ralph Becket
rbeck at microsoft.com
Fri Apr 27 21:18:07 AEST 2001
> Please help me obliterate this final error.
>
> [localhost:mercury/primality/divisors] metaperl% mmc -E --infer-all
divisors.m
> divisors.m:005: Error: no clauses for predicate `divisors:main/2'.
> divisors.m:010: Inferred :- pred --->(pred((io:state), (io:state)),
(pred)).
> [localhost:mercury/primality/divisors] metaperl%
This error message tells you the compiler cannot find a definition of
main/2.
It also informs you that it has inferred the type of a predicate you've
defined (but not given a signature for) called `--->/2'. This is a
strong
hint that the compiler is not seeing what you think you wrote.
>
> :- pred main(io__state::di, io__state::uo) is det.
This is the signature of main/2.
> :- implementation.
> :- import_module std_util, int, list.
>
> main ---> prime(12).
This is the `--->' arrow used in defining types; you want the `-->'
arrow
used to denote DCG code.
Even then, the expansion of main//0 will be to main/2 viz
main(IO0, IO) :- prime(12, IO0, IO).
but...
> :- pred prime(int).
> :- mode prime(in) is semidet.
>
> prime(N) :- N = smallest_divisor(N).
So, prime/1 takes one argument whereas your expanded main//0 predicate
calls prime/3 which doesn't exist.
More to the point, the prime/3 it's trying to call must have the
signature
:- pred prime(int, io__state, io__state).
:- mode prime(in, di, uo) is det.
Also, your prime/1 is semidet.
You have to make sure things match up.
-- 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