<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 am now working on an SDL wrapper I started back in 2019 and I have this type and predicate in the interface declaration of my wrapper:</div><div class=""><br class=""></div><div class=""><font face="Courier New" class="">:- type gfx_state.</font></div><div class=""><div class=""><div class=""><font face="Courier New" class="">:- pred startup(maybe.maybe(gfx_state)::out, io::di, io::uo) is det.</font></div><div class=""><font face="Courier New" class="">:- pred shutdown(gfx_state::in, io::di, io::uo) is det.</font></div><div class=""><font face="Courier New" class="">:- pred wnd_up(string::in, point::in, size::in, gfx_state::di, gfx_state::uo, io::di, io::uo) is det.</font></div></div></div><div class=""><br class=""></div><div class="">and in my main code where I start things up I have this code so far:</div><div class=""><br class=""></div><div class=""><div class=""><font face="Courier New" class=""> 27 main(!IO) :-</font></div><div class=""><font face="Courier New" class=""> 28 io.format("ui using gfx around sdl2\n", [], !IO),</font></div><div class=""><font face="Courier New" class=""> 29</font></div><div class=""><font face="Courier New" class=""> 30 gfx.startup(GM, !IO),</font></div><div class=""><font face="Courier New" class=""> 31 ( GM = yes(G),</font></div><div class=""><font face="Courier New" class=""> 32 io.format("GFX initialised OK\n", [], !IO),</font></div><div class=""><font face="Courier New" class=""> 33</font></div><div class=""><font face="Courier New" class=""> 34 gfx.wnd_up("Test", sdl2.point(0,0), sdl2.size(800,600),</font></div><div class=""><font face="Courier New" class=""> 35 G, G1, !IO),</font></div><div class=""><font face="Courier New" class=""> 36</font></div><div class=""><font face="Courier New" class=""> 37 gfx.shutdown(G1, !IO),</font></div><div class=""><font face="Courier New" class=""> 38 io.format("GFX halted OK\n", [], !IO)</font></div><div class=""><font face="Courier New" class=""> 39 ;</font></div><div class=""><font face="Courier New" class=""> 40 GM = no,</font></div><div class=""><font face="Courier New" class=""> 41 io.format("GFX failed to start\n", [], !IO)</font></div><div class=""><font face="Courier New" class=""> 42 ).</font></div></div><div class=""><br class=""></div><div class="">The sentiment was to call the startup predicate, if that returns yes(G) then G is the initial state of my graphics context. which like the IO state, I want to be able to use with !G etc, the above code produces these errors:</div><div class=""><br class=""></div><div class=""><div class=""><font face="Courier New" class="">mmc -s hlc.gc -O4 -lsdl2 -lSDL2_mixer -lSDL2_image --make main</font></div><div class=""><font face="Courier New" class="">Making Mercury/int3s/main.int3</font></div><div class=""><font face="Courier New" class="">Making Mercury/ints/main.int</font></div><div class=""><font face="Courier New" class="">Making Mercury/cs/main.c</font></div><div class=""><font face="Courier New" class="">main.m:034: In clause for `main(di, uo)':</font></div><div class=""><font face="Courier New" class="">main.m:034: in argument 4 of call to predicate `gfx.wnd_up'/7:</font></div><div class=""><font face="Courier New" class="">main.m:034: mode error: variable `G' has instantiatedness `ground',</font></div><div class=""><font face="Courier New" class="">main.m:034: expected instantiatedness was `unique'.</font></div><div class=""><font face="Courier New" class="">For more information, recompile with `-E'.</font></div><div class=""><font face="Courier New" class="">** Error making `Mercury/cs/main.c'.</font></div><div class=""><font face="Courier New" class="">make: *** [main] Error 1</font></div></div><div class=""><br class=""></div><div class="">I guess what I am asking is, how do I start the process of, creating the state variable in scope, the reference says that they have to be introduced into the head scope (like IO in my main is) but how do you do that in the body of codeā¦ I vaguely recollect some [Var] ringing a bell but I am confused a little by the terminology and hence exactly what to do about it!</div><div class=""><br class=""></div><div class="">Thank you.</div><div class="">Sean.</div><div class=""><br class=""></div><div class=""><br class=""></div></body></html>