<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,<div class=""><br class=""></div><div class="">I have created a virtual CPU in my transpiler called a TPU, text processing unit, it does the repetitive grunt work I need, and it has worked well so far but I now have a compiler error that whilst I understand what it means, I have failed to solve my problem. I might as well start with the declarations of things…</div><div class=""><br class=""></div><div class=""><font face="LektonNerdFontCompleteM-Regular" class=""> % Processor program inlined-code<br class=""> %<br class="">:- type tpu_inject == (pred(tpu_state, tpu_state)).<br class="">:- mode tpu_inject == (pred(in, out) is det).<br class=""><br class=""> % Processor Instruction Set.<br class=""> %<br class="">:- type tpu_inst<br class=""> ---> loads(ps)<br class=""> ; vartype<br class=""> ; identifier<br class=""> ; callterm(felt_options, int, call_term)<br class=""> ; t_indent(tpu_inject)<br class=""> .<br class=""> % Processor State.<br class="">:- type tpu_state<br class=""> ---> tpu_state(<br class=""> reg_ps1 :: ps, % REGISTER PS1<br class=""> reg_str1 :: string, % REGISTER STR1<br class=""> reg_str2 :: string, % REGISTER STR2<br class=""> reg_type1 :: string, % REGISTER TYPE1<br class=""> reg_fail :: bool % FAIL FLAG<br class=""> ).</font></div><div class=""><br class=""></div><div class="">A typical use of my processor is like this, the problem I have is that the final instruction, that renders indented text:</div><div class=""><br class=""></div><div class=""> tpu_runner(<br class=""> [ loads(ps(Pv, VName))<br class=""> , vartype<br class=""> , identifier<br class=""> , t_indent(<br class=""> (pred(!.State::in, !:State::out) is det :-<br class=""> trace[io(!Dbg), runtime(env("FELT_TRN"))]<br class=""> (<br class=""> ttrace(0, "INLINED!!!! %s", [s(string(!.State))], !Dbg)<br class=""> )<br class=""> )<br class=""> )<br class=""> ],<br class=""> TPU, !Tmap, !Errors<br class=""> )</div><div class=""><br class=""></div><div class="">The compiler error I get concerns the actual implementation of the program loop code, I have a disjunction on the instruction type, the code to execute an inlined closure is this,</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>:</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>:</div><div class=""><div class=""><font face="LektonNerdFontCompleteM-Regular" class=""> ;</font></div><div class=""><font face="LektonNerdFontCompleteM-Regular" class=""> Op = t_indent(Closure), <= <b class="">line 169</b></font></div><div class=""><font face="LektonNerdFontCompleteM-Regular" class=""> Closure(!S)</font></div><div class=""><font face="LektonNerdFontCompleteM-Regular" class=""> )</font></div></div><div class=""><br class=""></div><div class="">The line in bold is the source of the errors, those being that it says…</div><div class=""><br class=""></div><div class=""><div class="">tpu.m:169: In clause for `tpu_run(in, sub_identifier, sub_callterm, in, out,</div><div class="">tpu.m:169: out, in, out)':</div><div class="">tpu.m:169: in argument 1 (i.e. the predicate term) of higher-order predicate</div><div class="">tpu.m:169: call:</div><div class="">tpu.m:169: mode error: variable `Closure' has instantiatedness `ground',</div><div class="">tpu.m:169: expecting higher-order pred inst of arity 2.</div></div><div class=""><br class=""></div><div class="">I pass higher-order functions around with no issues as I have the pred and mode declarations correctyl defined but in this case, WHY is the compiler not seeing it as a higher order function despite the datatype t_indent(tpu_inject) and how do I tell it so?</div><div class=""><br class=""></div><div class="">Thanks</div><div class="">Sean</div><div class=""><br class=""></div></body></html>