[Ur] Running queryX1 once works; running it twice gives a compiler error

Stefan Scott Alexander stefanscottalexx at gmail.com
Tue Jul 28 02:50:22 EDT 2015


OK, I've been doing some localized, "surgical" modifications to test my
code, to see if I can pinpoint what part is causing the compile error "Some
constructor unification variables are undetermined in declaration",
mentioned in my previous post:

http://www.impredicative.com/pipermail/ur/2015-July/002109.html
https://github.com/StefanScott/urweb-colorThing_Fk
https://github.com/StefanScott/urweb-colorThing_Fk/issues/1

This compile error doesn't mention a specific line - it gives a big range
of lines, covering all the function definitions in the program.

The error message seems to be mentioning table 'color' (and it seems to
think the 'Id' column of 'color' is of type 'string' - but that column was
actually defined to be of type 'int').

So let's play with that part of the code. Here's the original:

  thingRows <-
    queryX1 (SELECT * FROM thing)
    (fn r => <xml> <tr>
               <td> {[r.Id]} </td>
               <td> {[r.Nam]} </td>
               <td> {[r.Color]} </td>
             </tr> </xml>);

  colorOptions <-
    queryX1 (SELECT * FROM color)
    (fn r => <xml> <option value={r.Id}> {[r.Nam]} </option> </xml>);

Let's try removing the second statement, which appears to be the
problematic one.

Results:

(1) If we *remove* the 2nd statement, which was setting 'colorOptions' (and
if we also modify the remainder of the code, so that it no longer
references 'colorOptions'), then this section now looks like this:

  thingRows <-
    queryX1 (SELECT * FROM thing)
    (fn r => <xml> <tr>
               <td> {[r.Id]} </td>
               <td> {[r.Nam]} </td>
               <td> {[r.Color]} </td>
             </tr> </xml>);

And now it COMPILES.

So this would seem to indicate that there was something wrong with the
statement which set 'colorOptions'.

But wait! Let's do one more test:

(2) If we *replace* the 2nd statement with a copy of the 1st statement (and
in the 2nd copy we change 'thingRows' to 'thingRows2' - and we also again
remove references to 'colorOptions' elsewhere in my code), then the code
looks like this:

  thingRows <-
    queryX1 (SELECT * FROM thing)
    (fn r => <xml> <tr>
               <td> {[r.TId]} </td>
               <td> {[r.TNam]} </td>
               <td> {[r.Color]} </td>
             </tr> </xml>);

  thingRows2 <-
    queryX1 (SELECT * FROM thing)
    (fn r => <xml> <tr>
               <td> {[r.TId]} </td>
               <td> {[r.TNam]} </td>
               <td> {[r.Color]} </td>
             </tr> </xml>);

AND NOW WE GET THE SAME COMPILE ERROR AS PREVIOUSLY (before we did any
modifications):

  "Some constructor unification variables are undetermined in declaration".

Question:

Cases (1) and (2) are identical. The only difference is that case (2) runs
the same statement twice, and assigns the second result to a new identifier.

Why would case (1) compile, while case (2) does not?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.impredicative.com/pipermail/ur/attachments/20150728/c691f820/attachment.html>


More information about the Ur mailing list