<div dir="ltr"><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div>Hello UrWeb users -<br><br></div>I've been learning UrWeb and and currently I'm studying Gian Perrone's excellent UrWeb tutorial (about creating a simple blog). <br><br>The existing code (<a href="https://github.com/gian/urtutorial">https://github.com/gian/urtutorial</a>) has been running fine.<br><br></div>Now I'm trying to do Excercise 7.3 on Step 7, here:<br><br><a href="http://www.expdev.net/urtutorial/step7.html">http://www.expdev.net/urtutorial/step7.html</a><br><br></div>I order to do this, I have been trying to:<br><br></div>- define a logout() function (a link which logs the user out, and sends them to a different "You have logged out!" page)<br><br></div>- add this link to all the pages in the application (when the user is authenticated)<br><br></div>I have been getting compiler errors, and I am unable to figure out how to do this correctly.<br><br>In order to show my code (and the compiler error messages - which can be rather lengthy) I have forked the tutorial on GitHub, and posted my attempted change there, along with the compiler output:<br><br><a href="https://github.com/DonaldScott/urtutorial/commit/78e0f6a4d0885744bf4729d674a46867bfdb4633">https://github.com/DonaldScott/urtutorial/commit/78e0f6a4d0885744bf4729d674a46867bfdb4633</a><br><br></div>I'm not sure if it's complaining about the type of the new functions which I added:<br><br>fun pageWithLogout pg =<br>   pg' <- pg;<br>   return <xml><br>            {pg'}<br>            <p><a link={logout()}>Logout</a></p><br>          </xml><br><br>and logout () = clearCookie userSession;<br>  return <xml>You have logged out!</xml><br><br></div>or maybe about something else ("unable to unify record types"?)<br><br></div>I believe the type of the two new functions being defined above should be [transaction page].<br><br></div>In order to "add" the link to an arbitrary page [pg], I have been attempting to:<br><br></div>- given a value [pg] of type [transaction page], "unwrap" the functional value contained inside it, using [pg' <- pg]<br><br></div>- "splice" the result into an xml fragment, using [<xml> ... {pg'} ... </xml>] while appending a link to the [logout()] function<br><br></div>- "wrap" the overall result in a value that is again of type [transaction page], using [return]<br><br></div>Intuitively, this seems to make sense (to me :-)<br><br>However, it is generating compiler errors - which may be about the above function - or may be about something else on the page, as it is mentioning "unable to unify record types" for various lines in the code - some of which are further below the new function being defined (the compiler is complaining about lines: 38, 57, 48, 31).<br><br></div>Thanks for any help!<br><br></div></div>