[Ur] XML unification problem

Sergey Mironov grrwlf at gmail.com
Fri Aug 9 07:04:58 EDT 2013


Hi. I continue my quest of implementing the 'reload in different
language' feature. This time I'm trying to avoid 'invalid link
expression' using pure functions. Unfortunately, with almost no
success.

Code below (and here [1]) triggers XML unification error (at the
bottom) which I can't understand. However, the code can be compiled if
one remove second (or first) call to 'reload <lang>'.

I've tried to reproduce the problem using simpler functions and
discovered that top-level references work well (that code is here
[2]).

Naturaly, I'm disapointed. I really want to have 1) several pages
sharing one template 2) ability to reload current page in a different
language.  Could you suggest other design patterns to handle my
usecase?

Sergey
[1] - https://github.com/grwlf/foocms/tree/master/tst/first-class-link-expr-4
[2] - https://github.com/grwlf/foocms/tree/master/tst/nested-xml-1

--- Code ---
(Also available here [1])

datatype lang = Ru | En

fun lang2str l = case l of Ru => "ru" | En => "en"

fun main' (l:lang) = let
  val reloader = fn (l':lang) => <xml><p><a link={main' l'}>Switch to
{[lang2str l']}</a></p></xml>
  in return (template reloader l) end

and template reload (l:lang) =
   <xml>
     <head>
       <title>MultyLang page</title>
     </head>
     <body>
       <h1>The body</h1>
       <p>Current page is in {[lang2str l]}</p>
       <p>The content</p>
       <p>Other languages:</p>
       {reload Ru}
       {reload En} (* Compiles if one remove second call to reload *)
     </body>
   </xml>

fun main {} = main' En

--- Error ---

[grwlf@ ~/proj/foocms/tst/first-class-link-expr-4 ]$ urweb -dbms sqlite app
/home/grwlf/proj/foocms/tst/first-class-link-expr-4/main.ur:29:3: (to
30:9) Unification failure
Expression:
Basis.join [<UNIF:U515::{Unit}>] [<UNIF:U516::{Type}>] [[]]
 [<UNIF:U518::{Type}>]
 (Basis.cdata [<UNIF:U515::{Unit}>] [<UNIF:U516::{Type}>] "\n")
 (Basis.join [<UNIF:U515::{Unit}>] [<UNIF:U516::{Type}>] [[]]
   [<UNIF:U518::{Type}>]
   (Basis.cdata [<UNIF:U515::{Unit}>] [<UNIF:U516::{Type}>] "       ")
   (Basis.join [<UNIF:U515::{Unit}>] [<UNIF:U516::{Type}>]
     [<UNIF:U518::{Type}>] [[]] (reload En)
     (Basis.join [<UNIF:U515::{Unit}>]
       [<UNIF:U516::{Type}> ++ <UNIF:U518::{Type}>] [[]] [[]]
       (Basis.cdata [<UNIF:U515::{Unit}>]
         [<UNIF:U516::{Type}> ++ <UNIF:U518::{Type}>] " ")
       (Basis.join [<UNIF:U515::{Unit}>]
         [<UNIF:U516::{Type}> ++ <UNIF:U518::{Type}>] [[]] [[]]
         (Basis.cdata [<UNIF:U515::{Unit}>]
           [<UNIF:U516::{Type}> ++ <UNIF:U518::{Type}>] "\n")
         (Basis.cdata [<UNIF:U515::{Unit}>]
           [<UNIF:U516::{Type}> ++ <UNIF:U518::{Type}>] "     ")))))
  Have con:
xml <UNIF:U515::{Unit}> <UNIF:U516::{Type}> <UNIF:U518::{Type}>
  Need con:
xml <UNIF:U515::{Unit}> (<UNIF:U516::{Type}> ++ <UNIF:U518::{Type}>)
 <UNIF:U510::{Type}>
Constructor occurs check failed
Have:  <UNIF:U516::{Type}>
Need:  <UNIF:U516::{Type}> ++ <UNIF:U518::{Type}>



More information about the Ur mailing list