<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">I wanted a list of environment variables in one hit so I wrote a predicate to do it…I initially a lambda in list.map but IO was complaining etc and so I wrote my version:<div class=""><br class=""><div class=""><span style="font-size: 14px; font-family: "Courier New";" class="">get_env_str(Vars, Out, !IO) :-</span><br class=""><div class=""><font face="Courier New" style="font-size: 14px;" class="">    get_env_str_list_(Vars, [], Out, !IO).<br class="">    % Aux.<br class="">:- pred get_env_str_list_(<br class="">    list(string)::in, list(string)::in, list(string)::out,<br class="">    io::di, io::uo) is det.<br class="">    % done, reverse.<br class="">get_env_str_list_([], Acc, Out, !_IO) :-<br class="">    Out = list.reverse(Acc).<br class="">    % find, prepend.<br class="">get_env_str_list_([V|Vs], Acc, Out, !IO) :-<br class="">    get_env_str(V, "", Val, !IO),<br class="">    get_env_str_list_(Vs, [Val|Acc], Out, !IO).</font></div><div class=""><br class=""></div><div class="">Then I called it like this:</div><div class=""><br class=""></div><div class=""><span style="font-family: "Courier New"; font-size: 14px;" class="">    utils.get_env_str([</span></div><div class=""><font face="Courier New" style="font-size: 14px;" class="">        "FELT_INST", "FELT_PAGER", "FELT_EDITOR",<br class="">        "FELT_REPL", "FELT_LEX", "FELT_AST"],<br class="">        [Inst, Pager, Editor, Repl, Lex, Ast],<br class="">        !IO),<br class=""></font></div><div class=""><br class=""></div><div class="">And got this:</div><div class=""><br class=""></div><div class=""><font face="Courier New" style="font-size: 14px;" class="">repl.m:248: In `run_info'(di, uo):<br class="">repl.m:248:   error: determinism declaration not satisfied.<br class="">repl.m:248:   Declared `det', inferred `semidet'.<br class="">repl.m:253:   In argument 2 of call to predicate `utils.get_env_str'/4:<br class="">repl.m:253:   in argument 2 of functor `[|]/2':<br class="">repl.m:253:   in argument 2 of functor `[|]/2':<br class="">repl.m:253:   in argument 2 of functor `[|]/2':<br class="">repl.m:253:   in argument 2 of functor `[|]/2':<br class="">repl.m:253:   in argument 2 of functor `[|]/2':<br class="">repl.m:253:   unification with `V_60' can fail.<br class="">repl.m:253:   In argument 2 of call to predicate `utils.get_env_str'/4:<br class="">repl.m:253:   in argument 2 of functor `[|]/2':<br class="">repl.m:253:   in argument 2 of functor `[|]/2':<br class="">repl.m:253:   in argument 2 of functor `[|]/2':<br class="">repl.m:253:   in argument 2 of functor `[|]/2':<br class="">... error log truncated, see `repl.err' for the complete log.<br class="">** Error making `Mercury/cs/repl.c’.</font></div><div class=""><br class=""></div><div class="">It took me a while to figure it out, but I reasoned that despite the fact I know I passed in six variable names, the compiler could not know how many values might well be in the returned list, despite me knowing that the internal implementation would always return the same number of strings, even a blank one. That then made sense of the error message, my final code then is:</div><div class=""><br class=""></div><div class=""><div style="background-color: rgb(240, 240, 240); font-family: "PT Mono", "Nouveau IBM Stretch", Menlo, Monaco, "Courier New", monospace, Menlo, Monaco, "Courier New", monospace; font-size: 12px; line-height: 22px; white-space: pre;" class=""><div class="">    utils.get_env_str([</div><div class="">        <span style="color: #032f62;" class="">"FELT_INST"</span>, <span style="color: #032f62;" class="">"FELT_PAGER"</span>, <span style="color: #032f62;" class="">"FELT_EDITOR"</span>,</div><div class="">        <span style="color: #032f62;" class="">"FELT_REPL"</span>, <span style="color: #032f62;" class="">"FELT_LEX"</span>, <span style="color: #032f62;" class="">"FELT_AST"</span>],</div><div class="">        Vars, !IO),</div><div class="">    ( Vars = [Inst, Pager, Editor, Repl, Lex, Ast]</div><div class="">    -> do stuff</div><div class="">    ; apologise to user</div><div class="">    ).</div><div class=""></div></div></div><div class="">Is that the correct reasoning behind the error? I hope so becaise I can’t really think of any other cause!</div><div class=""><br class=""></div><div class="">Thank you,</div><div class="">Sean.</div><div class=""><br class=""></div></div></div></body></html>