<html><head><meta http-equiv="content-type" content="text/html; charset=us-ascii"></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><div>I've been trying to produce a simple list of strings to output as the response to a command line argument request to list the supported targets of my transpiler, given I have a type and a predicate to return the printable string for the language I thought solutions/2 was my answer, but not so far! Again, it's a mixture of the terminology to my untutored brain and the lack of any really clear guiding examples, in Prolog this stuff is trivial!</div><div><br></div><div><br></div><div><font face="Courier New"> % Does -T / --targets.</font></div><div><font face="Courier New"> %</font></div><div><font face="Courier New">:- type supported_target</font></div><div><font face="Courier New"> ---> language_c</font></div><div><font face="Courier New"> ; language_python</font></div><div><font face="Courier New"> ; language_pythont</font></div><div><font face="Courier New"> ; language_js.</font></div><div><font face="Courier New"><br></font></div><div><font face="Courier New">:- pred show_targets(io::di, io::uo) is det.</font></div><div><font face="Courier New"><br></font></div><div><font face="Courier New"><b>300:</b>show_targets(!IO) :-</font></div><div><font face="Courier New"><b>301:</b> io.format("Available target languages:", [], !IO),</font></div><div><font face="Courier New"><b>302:</b> solutions(</font></div><div><font face="Courier New"><b>303:</b> (pred(A::out) is nondet :-</font></div><div><font face="Courier New"><b>304:</b> target_name(_, A)</font></div><div><font face="Courier New"><b>305:</b> ),</font></div><div><font face="Courier New"><b>306:</b> Targets</font></div><div><font face="Courier New"><b>307:</b> ),</font></div><div><font face="Courier New"><b>308:</b> io.print_line(Targets, !IO).</font></div><div><font face="Courier New"><br></font></div><div><font face="Courier New"><br></font></div><div><font face="Courier New"><br></font></div><div><font face="Courier New">:- pred target_name(supported_target, string).</font></div><div><font face="Courier New">:- mode target_name(in, out) is det.</font></div><div><font face="Courier New"><br></font></div><div><font face="Courier New">target_name(language_c, "Vanilla C").</font></div><div><font face="Courier New">target_name(language_python, "Vanilla Python").</font></div><div><font face="Courier New">target_name(language_pythont, "Typed Python").</font></div><div><font face="Courier New">target_name(language_js, "Vanilla JavaScript").</font></div><div><br></div><div>gives me the follwiong output:</div><div><br></div><div><div><font face="Courier New">command_line.m:308: In clause for `show_targets(di, uo)':</font></div><div><font face="Courier New">command_line.m:308: mode error in conjunction. The next 3 error messages</font></div><div><font face="Courier New">command_line.m:308: indicate possible causes of this error.</font></div><div><font face="Courier New">command_line.m:308:</font></div><div><font face="Courier New">command_line.m:303: In clause for `show_targets(di, uo)':</font></div><div><font face="Courier New">command_line.m:303: mode error in conjunction. The next 2 error messages</font></div><div><font face="Courier New">command_line.m:303: indicate possible causes of this error.</font></div><div><font face="Courier New">command_line.m:303:</font></div><div><font face="Courier New">command_line.m:304: In clause for `show_targets(di, uo)':</font></div><div><font face="Courier New">command_line.m:304: in argument 1 of call to predicate</font></div><div><font face="Courier New">command_line.m:304: `command_line.target_name'/2:</font></div><div><font face="Courier New">command_line.m:304: mode error: variable `V_5' has instantiatedness `free',</font></div><div><font face="Courier New">command_line.m:304: expected instantiatedness was `ground'.</font></div><div><font face="Courier New">command_line.m:303:</font></div><div><font face="Courier New">command_line.m:303: In clause for `show_targets(di, uo)':</font></div><div><font face="Courier New">command_line.m:303: in argument 1 of clause head:</font></div><div><font face="Courier New">command_line.m:303: mode error in unification of `LambdaHeadVar__1' and `A'.</font></div><div><font face="Courier New">command_line.m:303: Variable `LambdaHeadVar__1' has instantiatedness `free',</font></div><div><font face="Courier New">command_line.m:303: variable `A' has instantiatedness `free'.</font></div><div><font face="Courier New">command_line.m:308:</font></div><div><font face="Courier New">command_line.m:302: In clause for `show_targets(di, uo)':</font></div><div><font face="Courier New">command_line.m:302: in call to predicate `solutions.solutions'/2:</font></div><div><font face="Courier New">command_line.m:302: mode error: arguments `V_12, Targets' have the following</font></div><div><font face="Courier New">command_line.m:302: insts:</font></div><div><font face="Courier New">command_line.m:302: free,</font></div><div><font face="Courier New">command_line.m:302: free</font></div><div><font face="Courier New">command_line.m:302: which does not match any of the modes for predicate</font></div><div><font face="Courier New">command_line.m:302: `solutions.solutions'/2.</font></div><div><font face="Courier New">command_line.m:302: The first argument `V_12' has inst `free', which does not</font></div><div><font face="Courier New">command_line.m:302: match any of those modes.</font></div><div><font face="Courier New">command_line.m:308:</font></div><div><font face="Courier New">command_line.m:308: In clause for `show_targets(di, uo)':</font></div><div><font face="Courier New">command_line.m:308: in argument 1 of call to predicate `io.print_line'/3:</font></div><div><font face="Courier New">command_line.m:308: mode error: variable `Targets' has instantiatedness</font></div><div><font face="Courier New">command_line.m:308: `free',</font></div><div><font face="Courier New">command_line.m:308: expected instantiatedness was `ground'.</font></div></div><div><br></div><div><br></div><div>I've read the mercury crash course site with it's 'rows()' but so far drawn a blank...just how simple is it to get a list of possible solutions so that I may print a list of strings representing supported languages?</div><div><br></div><div>Thanks.</div><div><br></div></body></html>