[m-users.] Accumulator and mode declaration

Sean Charles (emacstheviking) objitsu at gmail.com
Thu May 6 07:55:11 AEST 2021


I understand the problem but I just can’t figure out the solution! I am passing an accumulator, I want to add strings to it as I go (eventually), I am so far in Prolog mode, learning Mercury as I port my code and I think I have hit a learning opportunity!

The code (tabs here for clarity, tabbing is 4-spaces in my file):

:- pred translate(
	list(string)::in, command_line.felt_options::in,
	io::di, io::uo) is det.

translate(Files, Options, !IO) :-
	translate_(Options, Files, [], !IO).


:- pred translate_(
	command_line.felt_options::in,
	list(string)::in,
	list(string)::out,
	io::di, io::uo) is det.

translate_(_, [], _Acc, !IO) :-
	trace [
		run_time(env("FELT_DBG")),
		io(!Dbg)
	]
	(io.format("translate_: all done\n", [], !Dbg)).

translate_(Options, [File|Files], Acc, !IO) :-
	trace [
		run_time(env("FELT_DBG")),
		io(!Dbg)
	]
	(io.format("translate_: %s\n", [s(File)], !Dbg)),
	translate_(Options, Files, Acc, !IO).

The error:

felt.m:074: In `translate'(in, in, di, uo):
felt.m:074:   error: determinism declaration not satisfied.
felt.m:074:   Declared `det', inferred `semidet'.
felt.m:084:   In argument 3 of call to predicate `felt.translate_'/5:
felt.m:084:   unification with `V_12' can fail.
felt.m:100: In clause for `translate_(in, in, out, di, uo)':
felt.m:100:   mode mismatch in disjunction.
felt.m:100:   The variable `HeadVar__3' has the following instantiation states.
felt.m:093:     In this branch, `HeadVar__3' has instantiatedness
felt.m:093:       free.
felt.m:100:     In this branch, `HeadVar__3' has instantiatedness
felt.m:100:       ground.

I —get— the error but I don’t know what to do!
Help!

:)
Sean

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/users/attachments/20210505/7a1a070d/attachment.html>


More information about the users mailing list