<div dir="ltr"><div>[Note: The following message can also be seen as a README on GitHub - with better formatting: <a href="https://github.com/StefanScott/UrWeb-Crud1-move-foldR">https://github.com/StefanScott/UrWeb-Crud1-move-foldR</a> ]</div><div><br></div><div>I am attempting make a minimal modification to the Crud1 demo, by moving the call to `@foldR` in `list()` to *before* the `return` statement. <br></div><div><br></div><div>The modified version now gives a kind unification error, apparently involving the 2nd argument to `@foldr` - `[ fn cols => xml form [] (map snd cols) ]`.</div><div><br></div><div>I am trying to figure out how such a minimal modification could result in a compile error.</div><div><br></div><div>The "diff" between the "before" and "after" can be seen at this link - also excerpted here below:</div><div><br></div><div><a href="https://github.com/StefanScott/UrWeb-Crud1-move-foldR/commit/04ca85962a5c95e8144c6e2a29df729d631b6187#diff-74e1ef1a69438025793099ad624ad8bcR63">https://github.com/StefanScott/UrWeb-Crud1-move-foldR/commit/04ca85962a5c95e8144c6e2a29df729d631b6187#diff-74e1ef1a69438025793099ad624ad8bcR63</a><br></div><div><br></div><div>BEFORE:</div><div><br></div><div>  return <xml> (* <= the `return` *)</div><div>  ...</div><div>  {@foldR  (* <= call to `@foldR`, will be moved *above* the `return` *)</div><div>      [ colMeta ] </div><div>      [ fn cols => xml form [] (map snd cols) ]</div><div>      ( fn [nm :: Name] [t ::_] [rest ::_] [[nm] ~ rest] (col : colMeta t) acc => </div><div>        <xml></div><div>          <li> {cdata col.Nam}: {col.Widget [nm]}</li></div><div>          {useMore acc}</div><div>        </xml> )</div><div>      <xml/></div><div>      M.fl </div><div>      M.cols} </div><div>  ...</div><div>  </xml></div><div><br></div><div>AFTER:</div><div><br></div><div>formFields <- @foldR (* <= call to `@foldR`, now moved *above* the `return` *)</div><div>  [ colMeta ] </div><div>  [ fn cols => xml form [] (map snd cols) ]</div><div>  ( fn [nm :: Name] [t ::_] [rest ::_] [[nm] ~ rest] (col : colMeta t) acc => </div><div>    <xml></div><div>      <li> {cdata col.Nam}: {col.Widget [nm]}</li></div><div>      {useMore acc}</div><div>    </xml> )</div><div>  <xml/></div><div>  M.fl </div><div>  M.cols;</div><div>  return <xml> (* <= the `return` *)</div><div>  ...</div><div>  {formFields} (* <= call to `@foldR` was originally here *)</div><div>  ...</div><div>  </xml></div><div><br></div><div>I created a GitHub with just 2 commits, to illustrate the modification:</div><div><br></div><div>  - commit 0: the original Crud1 (simplified to only do SELECT and INSERT); </div><div><br></div><div>  - commit 1: the modified Crud1 - now, in function `list()`, the call to `@foldR` which computes the form fields has been moved to *before* the `return`. This gives following compile error:</div><div><br></div><div><a href="https://github.com/StefanScott/UrWeb-Crud1-move-foldR/blob/master/ERR.001.crudWidgetTxn1.ur">https://github.com/StefanScott/UrWeb-Crud1-move-foldR/blob/master/ERR.001.crudWidgetTxn1.ur</a><br></div><div><br></div><div>The modified version gives a kind unification failure:</div><div><br></div><div>  Have con: </div><div><br></div><div>  xml ([Dyn = (), Body = (), Form = ()]) ([])</div><div>   (map (fn t :: (Type * Type) => t.2) M.cols)</div><div><br></div><div>  Need con:  </div><div><br></div><div>  <UNIF:U408::Type -> Type> <UNIF:U409::Type></div><div><br></div><div>  Kind unification failure</div><div><br></div><div>  Have:  {Type} -> Type</div><div>  Need:  Type -> Type</div><div><br></div><div>This appears to involve the second argument to `@foldR`, which is:</div><div><br></div><div>  [ fn cols => xml form [] (map snd cols) ]</div><div><br></div><div>I thought that merely moving a chunk of code before a `return` statement like this wouldn't change much, so I don't understand what might be causing this kind unification failure in the modified version.</div><div><br></div><div>Thanks for any help!</div><div><br></div><div>###</div><div><br></div></div>