<div dir="ltr"><div><div><font face="monospace, monospace">Thank you Ziv for these 2 very helpful suggestions - they seem to be heading in the right direction.</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">I have incorporated them, and now I'm getting different (but possibly "better"?) compiler errors.</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">Suggestion (1)</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">You provided a reminder of your earlier suggestion to use this pattern:</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">  <textbox{#Field} id={nid}/></font></div><div><font face="monospace, monospace">  <active code={init nid; return <xml/>}/></font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">This does seem like a vast improvement over my previous code (which had an `onload` event in the <body> tag, which I had simply copied from David Patterson's "Democracy Now" example) - since, as you pointed out, the `onload` event was probably problematic, because the node in question probably didn't exist yet.</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">I have now changed the code as follows:</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">  <a href="https://github.com/StefanScott/urweb-pikaday/blob/master/pikadayPage.ur">https://github.com/StefanScott/urweb-pikaday/blob/master/pikadayPage.ur</a></font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">OLD:</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">  <form onload={init foo_id}></font></div><div><font face="monospace, monospace">    <textbox{#DateField} id={foo_id}/></font></div><div><font face="monospace, monospace">    <submit action={handler}/></font></div><div><font face="monospace, monospace">  </form></font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">NEW:</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">  <form></font></div><div><font face="monospace, monospace">    <textbox{#DateField} id={foo_id}/></font></div><div><font face="monospace, monospace">    <active code={init foo_id; return <xml/>}/></font></div><div><font face="monospace, monospace">    <submit action={handler}/></font></div><div><font face="monospace, monospace">  </form></font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">This now gave the following compile errors:</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">$ urweb pikadayPage</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">pikadayPage.ur:27:3: (to 29:12) Error in final record unification</font></div><div><font face="monospace, monospace">Can't unify record constructors</font></div><div><font face="monospace, monospace">Have:  [Dyn = (), MakeForm = (), Body = ()]</font></div><div><font face="monospace, monospace">Need:  [Form = (), Dyn = (), Body = ()]</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">pikadayPage.ur:27:3: (to 29:12) Stuck unifying these records after canceling matching pieces:</font></div><div><font face="monospace, monospace">Have:  [MakeForm = ()]</font></div><div><font face="monospace, monospace">Need:  [Form = ()]</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">pikadayPage.ur:28:3: (to 29:12) Error in final record unification</font></div><div><font face="monospace, monospace">Can't unify record constructors</font></div><div><font face="monospace, monospace">Have:  <UNIF:U526::{Unit}> ++ [Form = ()]</font></div><div><font face="monospace, monospace">Need:  [Dyn = (), MakeForm = (), Body = ()]</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">pikadayPage.ur:28:3: (to 29:12) Stuck unifying these records after canceling matching pieces:</font></div><div><font face="monospace, monospace">Have:  ([Form = ()]) ++ <UNIF:U526::{Unit}></font></div><div><font face="monospace, monospace">Need:  [Dyn = (), MakeForm = (), Body = ()]</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">$ </font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">Well... It looks like the compiler is *almost* happy - if the only conflict now remaining is between a MakeForm field and a Form field. </font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">However, I do not know what these two fields mean, or where they come from, so I don't know how to attempt to resolve this compile error.</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">Suggestion (2):</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">I haven't yet tried creating a wrapper function </font><span style="font-family:monospace,monospace">(like `activate` in Logitext) </span><span style="font-family:monospace,monospace">in accordance with your second suggestion - but after (ie, in addition to) doing suggestion (1) above, I did also try making a quick change to the result type in pikadayControl.urs - changing it from `transaction unit` to `transaction xbody`:</span></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">  <a href="https://github.com/StefanScott/urweb-pikaday/blob/master/pikadayControl.urs">https://github.com/StefanScott/urweb-pikaday/blob/master/pikadayControl.urs</a></font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">OLD:</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">val init : </font></div><div><font face="monospace, monospace">  id -> </font></div><div><font face="monospace, monospace">  transaction unit</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">NEW:</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">val init : </font></div><div><font face="monospace, monospace">  id -> </font></div><div><font face="monospace, monospace">  transaction xbody</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">I was expecting that this might actually compile, since it seemed that the new "result type" `transaction xbody` might be more appropriate for use in the <active> tag added in Suggestion (1):</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">  <active code={init foo_id; return <xml/>}/></font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">However, this gave a different (but possibly also helpful?) compile error:</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">$ urweb pikadayPage</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">pikadayPage.ur:27:24: (to 27:54) Unification failure</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">Expression: </font></div><div><font face="monospace, monospace">fn _ : {} =></font></div><div><font face="monospace, monospace"> return [<UNIF:U458::Type -> Type>]</font></div><div><font face="monospace, monospace">  [xml <UNIF:U460::{Unit}> <UNIF:U461::{Type}> ([])] _</font></div><div><font face="monospace, monospace">  (Basis.cdata [<UNIF:U460::{Unit}>] [<UNIF:U461::{Type}>] "")</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">Have con: </font></div><div><font face="monospace, monospace">{} -></font></div><div><font face="monospace, monospace"> <UNIF:U458::Type -> Type></font></div><div><font face="monospace, monospace">  (xml <UNIF:U460::{Unit}> <UNIF:U461::{Type}> ([]))</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">Need con: </font></div><div><font face="monospace, monospace">(xml ([Dyn = (), MakeForm = (), Body = ()]) ([]) ([])) -></font></div><div><font face="monospace, monospace"> transaction <UNIF:U453::Type></font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">Incompatible constructors</font></div><div><font face="monospace, monospace">Have:  {}</font></div><div><font face="monospace, monospace">Need:  xml ([Dyn = (), MakeForm = (), Body = ()]) ([]) ([])</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">$ </font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">This error message seems somewhat similar to the previous error message. It seems to be saying that there is some incompatibility among the following pieces:</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">(a) the "result type" of function `init` as declared in file pikadayControl.urs</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">(b) the "result type" of the curly-bracketed expression in the tag:</font></div><div><font face="monospace, monospace"><br></font></div><div><div><font face="monospace, monospace">  <active code={init foo_id; return <xml/>}/></font></div></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">(c) possibly also the "result type" being returned by the JavaScript `init` function as defined in pikadayControl.js</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">The JavaScript `init` function:</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">By the way, here is the JavaScript function `init`:</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"><a href="https://github.com/StefanScott/urweb-pikaday/blob/master/pikadayControl.js">https://github.com/StefanScott/urweb-pikaday/blob/master/pikadayControl.js</a></font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">function init ( nodeId ) = {</font></div><div><font face="monospace, monospace">  var picker = new Pikaday ( { </font></div><div><font face="monospace, monospace">    field: document.getElementById(nodeId),</font></div><div><font face="monospace, monospace">    firstDay: 1,</font></div><div><font face="monospace, monospace">    minDate: new Date('2000-01-01'),</font></div><div><font face="monospace, monospace">    maxDate: new Date('2020-12-31'),</font></div><div><font face="monospace, monospace">    yearRange: [2000,2020]</font></div><div><font face="monospace, monospace">  } ) ;</font></div><div><font face="monospace, monospace">}</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">It is a slight modification of the JavaScript provided in the Pikaday demo:</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">  <a href="http://dbushell.github.io/Pikaday/">http://dbushell.github.io/Pikaday/</a><br></font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">Thiss JavaScript function appears to take an argument `nodeId`, and creates a `new Pikaday` attached to that node, assigning the result to a variable called `picker` </font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">I don't *think* this JavaScript `init` function actually returns anything: apparently the `var picker` is merely a "throwaway" (?) and the function is being run simply for its side-effect (attaching the `new Pikaday` to the node `nodeId`)? </font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">This makes me wonder if the "result type" of this `init` function (in JavaScript) might also dictate the "result type" of its corresponding Ur/Web FFI declaration (which was previously `transaction unit` and is now `transaction xbody`).</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">Remarks:</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">The compile error messages are providing intriguing clues about these interdependencies between the various pieces.</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">However, I don't yet have enough experience in this area to be able to have a truly "deterministic" methodology for writing this stuff - I'm simply using trial and error, throwing various syntaxes at the compiler and trying to decipher the error messages.</font></div></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">Thanks for any further help!</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">###</font></div><div><br></div></div>