[mercury-users] Seemingly spurious 'some but not all arguments have modes' error.
Julian Fondren
ayrnieu at gmail.com
Sun Feb 11 04:19:38 AEDT 2007
This error:
partialmode.m:026: Error: some but not all arguments have modes:
command((string :: in), out(pred((list(dummy) :: in), (io :: di), (io
:: uo)) is det)).
partialmode.m:027: Error: clause for predicate `partialmode.command/2'
partialmode.m:027: without preceding `pred' declaration.
partialmode.m:027: Inferred :- pred command(string,
pred((list.list((partialmode.dummy))), (io.state), (io.state))).
partialmode.m:027: Error: no mode declaration for predicate
partialmode.m:027: `partialmode.command/2'.
partialmode.m:027: (Use `--infer-modes' to enable mode inference.)
partialmode.m:027: Inferred :- mode command(in, out(/* unique */(pred((ground
partialmode.m:027: >> ground), (unique >> clobbered), (free >> unique)) is
partialmode.m:027: det))).
comes from the trailing module. Using the commented pred/mode
declarations, it compiles and operates without remark. The
first line of the error message seems really strange, in that
it shows nicely moded arguments.
Cheers,
Julian
:- module partialmode.
:- interface.
:- import_module io.
:- pred main(io::di, io::uo) is det.
:- implementation.
:- import_module bool, list, string, require.
:- type dummy
---> dummy(
name :: string,
is_mortal :: bool
).
main(!IO) :-
Args = ["dump"],
(
command(list.head(Args), Command)
->
Command([dummy("socrates", yes),dummy("plato", yes)], !IO)
;
error("inconceivable!")
).
:- pred command(string, (pred(list(dummy), io, io))).
:- mode command(in, out(pred(in, di, uo) is det)) is semidet.
% :- pred command(string::in, out(pred(list(dummy)::in, io::di,
io::uo) is det)) is semidet.
command("dump", dump).
:- pred dump(list(dummy)::in, io::di, io::uo) is det.
dump([], !IO).
dump([H | T], !IO) :-
io.format("%s - %s\n", [s(H^name), s(to_string(H^is_mortal))], !IO),
dump(T, !IO).
:- func to_string(bool) = string.
to_string(yes) = "yes".
to_string(no) = "no".
--------------------------------------------------------------------------
mercury-users mailing list
Post messages to: mercury-users at csse.unimelb.edu.au
Administrative Queries: owner-mercury-users at csse.unimelb.edu.au
Subscriptions: mercury-users-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the users
mailing list