<div dir="ltr"><span style="font-size:12.8px">Hello all,</span><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">I am trying to use a structure but, I am stuck at one point. This is my structure definition -</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><br></div><div><div><span style="font-size:12.8px"><b>functor Make(M : sig</b></span></div><div><span style="font-size:12.8px"><b>                 val callback : _</b></span></div><div><span style="font-size:12.8px"><b>             end) = struct</b></span></div><div><span style="font-size:12.8px"><b>    val cb  = M.callback</b></span></div><div><span style="font-size:12.8px"><b><br></b></span></div><div><span style="font-size:12.8px"><b>    fun simple nn =</b></span></div><div><span style="font-size:12.8px"><b>        cb(nn);</b></span></div><div><span style="font-size:12.8px"><b>        return nn</b></span></div><div><span style="font-size:12.8px"><b>end</b></span></div></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">What I am trying to do is to initiate a structure with a callback function. Below demonstrates using a function debugMe as a callback. This works totally fine.</span><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px"><br></span></div><div><div><div><b>fun debugMe a =</b></div><div><b>        alert a</b></div><div><b><br></b></div><div><b>structure AB = Mymaths.Make(struct</b></div><div><b>                               val callback = debugMe</b></div><div><b>                           end)</b></div><div><b><br></b></div><div><b>fun main()=</b></div><div><b>let</b></div><div><b>    fun callMe () =</b></div><div><b>        x <- AB.simple "test";</b></div><div><b>        debug x</b></div><div><b><br></b></div><div><b>in</b></div><div><b>    return <xml></b></div><div><b>        <body></b></div><div><b>            <h1> Sample </h1></b></div><div><b>            <button value="Click Me" onclick={fn _ => callMe()}></button></b></div><div><b>        </body></b></div><div><b>        </xml></b></div><div><b>end</b></div><div><br></div></div><div style="font-size:12.8px"><br></div></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><div style="font-size:12.8px">What I ultimately want to achieve is to be able to change the callback function <i>debugMe</i> at a later point of time. Is it possible to set or update values within a structure at a later point of time?</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">I am new to urweb and SML in general so pardon me if this is really silly. Any help would be really appreciated. Thanks a lot!</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Regards,</div><div style="font-size:12.8px">Harshita</div></div></div>