<div dir="ltr"><div><span style="font-family:monospace,monospace">In order to minimize possible errors, I am trying to do minimal example of a `<select>` widget to edit a foreign-key field, but I am still getting a compile error "Some constructor unification variables are undetermined". </span><br></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">Strangely, this error message mentions a field [Id = string] - but my code only uses [Id = int].</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">The code is on GitHub (and also reproduced at the end of this message). It's very short and simple:<br></font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"><a href="https://github.com/StefanScott/urweb-colorThing_Fk">https://github.com/StefanScott/urweb-colorThing_Fk</a><br></font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">It uses only two tables ("parent" table 'color', and "child" table 'thing'):</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">```</font></div><div><font face="monospace, monospace">table color : { </font></div><div><font face="monospace, monospace">  Id : int, </font></div><div><font face="monospace, monospace">  Nam : string </font></div><div><font face="monospace, monospace">}</font></div><div><font face="monospace, monospace">PRIMARY KEY Id</font></div><div><font face="monospace, monospace"> </font></div><div><font face="monospace, monospace">table thing : {</font></div><div><font face="monospace, monospace">  Id : int, </font></div><div><font face="monospace, monospace">  Nam : string,</font></div><div><font face="monospace, monospace">  Color : int</font></div><div><font face="monospace, monospace">}</font></div><div><font face="monospace, monospace">PRIMARY KEY Id,</font></div><div><font face="monospace, monospace">CONSTRAINT Thing_isof_Color FOREIGN KEY Color REFERENCES color(Id)</font></div><div><font face="monospace, monospace">```</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">It also makes the following additional simplifications:</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">- no sequence or auto-increment (ie, the user has to create the primary key)</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">- no meta-programming</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">- no Ur/Web modules, structures, functors or libraries</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">- web interface provided only for *creating* records in table 'thing' (no updating or deleting)</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">- no web interface provided for creating, updating or deleting 'color' records (must do this via via psql)</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">The Ur/Web compiler gives the following error:</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">```</font></div><div><font face="monospace, monospace">Some constructor unification variables are undetermined in declaration</font></div><div><font face="monospace, monospace">(look for them as "<UNIF:...>")</font></div><div><font face="monospace, monospace">```</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">It can be difficult to debug this error, as it refers to a wide range of lines (covering all the function definitions).</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">Clue:</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">There is one interesting clue in the compiler error message: it frequently mentions a field:</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">```</font></div><div><font face="monospace, monospace">Id = string</font></div><div><font face="monospace, monospace">```</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">However, both instances of 'Id' defined in the program (the primary keys of tables 'thing' and 'color') have type 'int', not 'string'.</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">I'm very puzzled. Can anyone help explain this compile error?</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">The compile output is reproduced in Issue 1 of the GitHub repo:</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"><a href="https://github.com/StefanScott/urweb-colorThing_Fk/issues/1">https://github.com/StefanScott/urweb-colorThing_Fk/issues/1</a><br></font></div><div><br></div><div><font face="monospace, monospace">---------</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">Below is the complete source code of colorThing_Fk.ur (also on GitHub). It's very short, in order to make it easier find the error!</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"><a href="https://github.com/StefanScott/urweb-colorThing_Fk">https://github.com/StefanScott/urweb-colorThing_Fk</a><br></font></div><div><font face="monospace, monospace"><br></font></div><div><div><font face="monospace, monospace">table color : {</font></div><div><font face="monospace, monospace">  Id : int, </font></div><div><font face="monospace, monospace">  Nam : string</font></div><div><font face="monospace, monospace">}</font></div><div><font face="monospace, monospace">  PRIMARY KEY Id,</font></div><div><font face="monospace, monospace">  CONSTRAINT Nam UNIQUE Nam,</font></div><div><font face="monospace, monospace">  CONSTRAINT Id CHECK Id >= 0</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">table thing : {</font></div><div><font face="monospace, monospace">  Id : int, </font></div><div><font face="monospace, monospace">  Nam : string,</font></div><div><font face="monospace, monospace">  Color : int</font></div><div><font face="monospace, monospace">}</font></div><div><font face="monospace, monospace">  PRIMARY KEY Id,</font></div><div><font face="monospace, monospace">  CONSTRAINT Id CHECK Id >= 0,</font></div><div><font face="monospace, monospace">  CONSTRAINT Thing_isof_Color FOREIGN KEY Color REFERENCES color(Id)</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">fun list () =</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">  thingRows <- </font></div><div><font face="monospace, monospace">    queryX1 (SELECT * FROM thing)</font></div><div><font face="monospace, monospace">    (fn r => <xml> <tr> </font></div><div><font face="monospace, monospace">               <td> {[r.Id]} </td> </font></div><div><font face="monospace, monospace">               <td> {[r.Nam]} </td> </font></div><div><font face="monospace, monospace">               <td> {[r.Color]} </td> </font></div><div><font face="monospace, monospace">             </tr> </xml>);</font></div><div><font face="monospace, monospace">  colorOptions <- </font></div><div><font face="monospace, monospace">    queryX1 (SELECT * FROM color)</font></div><div><font face="monospace, monospace">    (fn r => <xml> <option value={r.Id}> {[r.Nam]} </option> </xml>);</font></div><div><font face="monospace, monospace">  return</font></div><div><font face="monospace, monospace">    <xml></font></div><div><font face="monospace, monospace">      <table border={1}></font></div><div><font face="monospace, monospace">        <tr> <th>Id</th> <th>Nam</th> <th>Color</th> </tr></font></div><div><font face="monospace, monospace">        {thingRows}</font></div><div><font face="monospace, monospace">      </table></font></div><div><font face="monospace, monospace">      <br/><hr/><br/></font></div><div><font face="monospace, monospace">      <form></font></div><div><font face="monospace, monospace">        <table></font></div><div><font face="monospace, monospace">          <tr> <th>A:</th> <td><textbox{#Id}/></td> </tr></font></div><div><font face="monospace, monospace">          <tr> <th>B:</th> <td><textbox{#Nam}/></td> </tr></font></div><div><font face="monospace, monospace">          <tr> <th>C:</th> <td><select{#Color}>{colorOptions}</select></td> </tr></font></div><div><font face="monospace, monospace">          <tr> <th/> <td><submit action={create} value="Add Row"/></td> </tr></font></div><div><font face="monospace, monospace">        </table></font></div><div><font face="monospace, monospace">      </form></font></div><div><font face="monospace, monospace">    </xml></font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">and create r  =</font></div><div><font face="monospace, monospace">  dml (INSERT INTO thing (Id, Nam, Color) </font></div><div><font face="monospace, monospace">       VALUES ({[readError r.Id]}, {[r.Nam]}, {[readError r.Color]}));</font></div><div><font face="monospace, monospace">  ls <- list ();</font></div><div><font face="monospace, monospace">  return</font></div><div><font face="monospace, monospace">    <xml><body></font></div><div><font face="monospace, monospace">      <p>Thing inserted!</p></font></div><div><font face="monospace, monospace">      {ls}</font></div><div><font face="monospace, monospace">    </body></xml></font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">and main () =</font></div><div><font face="monospace, monospace">  ls <- list ();</font></div><div><font face="monospace, monospace">  return <xml><body></font></div><div><font face="monospace, monospace">    <h1>Things</h1></font></div><div><font face="monospace, monospace">    {ls}</font></div><div><font face="monospace, monospace">  </body></xml></font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">---------</font></div></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">Thanks for any help!</font></div><div><br></div></div>