<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="">Hi Volker, I use code like this all the time for !IO and folding,<div class=""><br class=""></div><div class=""><div class=""><font face="Courier New" style="font-size: 14px;" class="">run_info(Options, !IO) :-</font></div><div class=""><font face="Courier New" style="font-size: 14px;" class="">    aio.format("@cy:Environment variables:@-\n", [], !IO),</font></div><div class=""><font face="Courier New" style="font-size: 14px;" class=""><br class=""></font></div><div class=""><font face="Courier New" style="font-size: 14px;" class="">    list.foldl(</font></div><div class=""><font face="Courier New" style="font-size: 14px;" class="">        (pred(S::in, !.IO::di, !:IO::uo) is det :-</font></div><div class=""><font face="Courier New" style="font-size: 14px;" class="">            get_env_str(S, "", ENV, !IO),</font></div><div class=""><font face="Courier New" style="font-size: 14px;" class="">            aio.format("@yl:%15s:@- %s\n",</font></div><div class=""><font face="Courier New" style="font-size: 14px;" class="">                [s(S), s(ENV)],</font></div><div class=""><font face="Courier New" style="font-size: 14px;" class="">                !IO)</font></div><div class=""><font face="Courier New" style="font-size: 14px;" class="">        ), ["FELT_INST", "FELT_DOCS", "FELT_PAGER", "FELT_EDITOR",</font></div><div class=""><font face="Courier New" style="font-size: 14px;" class="">            "FELT_LEX",  "FELT_AST",  "FELT_TRN"],</font></div><div class=""><font face="Courier New" style="font-size: 14px;" class="">        !IO),</font></div><div class=""><font face="Courier New" style="font-size: 14px;" class=""><br class=""></font></div><div class=""><font face="Courier New" style="font-size: 14px;" class="">    aio.format("@cy:Command line options:@-\n", [], !IO),</font></div><div class=""><font face="Courier New" style="font-size: 14px;" class=""><br class=""></font></div><div class=""><font face="Courier New" style="font-size: 14px;" class="">    list.foldl(</font></div><div class=""><font face="Courier New" style="font-size: 14px;" class="">        (pred(K::in, !.IO::di, !:IO::uo) is det :-</font></div><div class=""><font face="Courier New" style="font-size: 14px;" class="">            map.lookup(Options, K, V),</font></div><div class=""><font face="Courier New" style="font-size: 14px;" class="">            aio.format("@yl:%15s:@- %s\n",</font></div><div class=""><font face="Courier New" style="font-size: 14px;" class="">                [s(string(K)), s(string(V))],</font></div><div class=""><font face="Courier New" style="font-size: 14px;" class="">                !IO)</font></div><div class=""><font face="Courier New" style="font-size: 14px;" class="">        ),</font></div><div class=""><font face="Courier New" style="font-size: 14px;" class="">        map.sorted_keys(Options),</font></div><div class=""><font face="Courier New" style="font-size: 14px;" class="">        !IO).</font></div></div><div class=""><br class=""></div><div class="">Like Zoltan says, the code practically writes itself, I’ve not found the need to for threading !IO through anything to be honest!</div><div class=""><br class=""></div><div class="">All the best,</div><div class="">Sean</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On 21 Dec 2021, at 16:21, Volker Wysk <<a href="mailto:post@volker-wysk.de" class="">post@volker-wysk.de</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">Am Mittwoch, dem 22.12.2021 um 02:51 +1100 schrieb Zoltan Somogyi:<br class=""><blockquote type="cite" class=""><br class="">On Tue, 21 Dec 2021 16:18:48 +0100, Volker Wysk <<a href="mailto:post@volker-wysk.de" class="">post@volker-wysk.de</a>> wrote:<br class=""><blockquote type="cite" class="">I'm using four meta-predicates which deal with loops and IO, and I find them<br class="">useful. Maybe you want to include them in the Mercury libraries?<br class=""></blockquote><br class="">Three out of the four are already there, in more general forms. Instead of<br class="">the last pair of arguments required to be I/O states, they can be any type,<br class="">and their modes do not have to be di/uo; they can be e.g. in/out.<br class=""></blockquote><br class="">Now I'm feeling bashful... :) In the future, I'll make it a habit to read<br class="">the documentation more thoroughly. It's, in part, because I didn't fully<br class="">understand what was meant by "accumulator". (I have a different<br class="">understanding of it).<br class=""><br class="">Bye, Volker<br class=""><br class="">_______________________________________________<br class="">users mailing list<br class=""><a href="mailto:users@lists.mercurylang.org" class="">users@lists.mercurylang.org</a><br class="">https://lists.mercurylang.org/listinfo/users<br class=""></div></div></blockquote></div><br class=""></div></body></html>