Harshita Kasera
2017-11-10 03:42:22 UTC
Hello all,
I am trying to use a structure but, I am stuck at one point. This is my
structure definition -
*functor Make(M : sig*
* val callback : _*
* end) = struct*
* val cb = M.callback*
* fun simple nn =*
* cb(nn);*
* return nn*
*end*
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.
*fun debugMe a =*
* alert a*
*structure AB = Mymaths.Make(struct*
* val callback = debugMe*
* end)*
*fun main()=*
*let*
* fun callMe () =*
* x <- AB.simple "test";*
* debug x*
*in*
* return <xml>*
* <body>*
* <h1> Sample </h1>*
* <button value="Click Me" onclick={fn _ => callMe()}></button>*
* </body>*
* </xml>*
*end*
What I ultimately want to achieve is to be able to change the callback
function *debugMe* at a later point of time. Is it possible to set or
update values within a structure at a later point of time?
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!
Regards,
Harshita
I am trying to use a structure but, I am stuck at one point. This is my
structure definition -
*functor Make(M : sig*
* val callback : _*
* end) = struct*
* val cb = M.callback*
* fun simple nn =*
* cb(nn);*
* return nn*
*end*
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.
*fun debugMe a =*
* alert a*
*structure AB = Mymaths.Make(struct*
* val callback = debugMe*
* end)*
*fun main()=*
*let*
* fun callMe () =*
* x <- AB.simple "test";*
* debug x*
*in*
* return <xml>*
* <body>*
* <h1> Sample </h1>*
* <button value="Click Me" onclick={fn _ => callMe()}></button>*
* </body>*
* </xml>*
*end*
What I ultimately want to achieve is to be able to change the callback
function *debugMe* at a later point of time. Is it possible to set or
update values within a structure at a later point of time?
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!
Regards,
Harshita