[Ur] new user having some questions such as a:::Type twice? and more
    Marc Weber 
    marco-oweber at gmx.de
       
    Wed Sep 29 09:18:19 EDT 2010
    
    
  
Hi list.
1)
  Which is the correct type for my_length2
  The line below "TYPE 1" show how to it for my_length
  my_length2 takes two lists and sums both length. (There is no use case
  but learning ur for this function)
  val rec my_length
    (* TYPE 1 *)
    : a:::Type -> list a -> int
    = fn [a:::Type] (li: list a) =>
                    case li of
                        [] => 0
                        | _ :: ls => 1 + my_length ls
  val my_length2
    (* TYPE 2 *)
    (*: What is the type of this function *)
    = fn [a:::Type] [b:::Type] (li: list a, lj: list b) =>
                      ( my_length li + my_length lj )
  fun main () =
      let
        val add3: int -> int = fn x => x +1
      in
      (* show (1,2) *)
      return <xml><body>
        <div>
          {[ my_length(Cons(1, [])) ]}
          <br/>
          {[ my_length2(Cons(1, []), Cons("1", [])) ]}
        </div>
      </body></xml>
      end
2)
  comparing my_length above with the one by lib/ur/list.ur I think
  my_length is much simpler. So why is lib/ur/list.ur using acc?
  lib/ur/list.ur:
    val length = fn [a] =>
                    let
                        fun length' acc (ls : list a) =
                            case ls of
                                [] => acc
                              | _ :: ls => length' (acc + 1) ls
                    in
                        length' 0
                    end
3) Is there a way to comment lines in .urp files?
4)
  How would you feel about adding //, #  or-- like comments which always
  comment everything until end of line?
5) Has anyone already thought about adding pdf support in some way -
   probably by interfacing with C?
6) speed:
   I did some benchmarking:
   url_1,2,3 are a *very* simple xml documents.
   So I added more and more of them taking time.
   the main page contains N <a ..> tags and main.ur 
   contains N url_N functions:
    fun main () =
      return <xml>
        <head> <title>Hello world!!</title> </head>
        <body>
          <h1>My tests</h1>
    <a link={url_1()}>url1</a>
    [...]
          </body>
        </xml>
        and url_1 () = return <xml><body> <a href="http://en.wikipedia.org/wiki/Type_inference">Learn something</a><br/> <br/> <form> URL of your choice: <textbox{#Url}/> </form> </body></xml>
        and url_2 () = return <xml><body> <a href="http://en.wikipedia.org/wiki/Type_inference">Learn something</a><br/> <br/> <form> URL of your choice: <textbox{#Url}/> </form> </body></xml>
    [...]
         
    results:
                        
       | num of url_1 functions | timing in sec         | num / timing
      20 exit code was 0timing :1.37693095207214 ratio: 0.0688465476036072
      40 exit code was 0timing :2.38593482971191 ratio: 0.0596483707427979
      80 exit code was 0timing :5.21924781799316 ratio: 0.0652405977249146
      160 exit code was 0timing :8.78839206695557 ratio: 0.0549274504184723
      320 exit code was 0timing :18.0503919124603 ratio: 0.0564074747264385
      640 exit code was 0timing :40.8116230964661 ratio: 0.0637681610882282
    Which means about 50ms typing time for each additional and url_ = ... ?
    This seems to be a lot to me.
    if I use fun NAME only putting the functions above main I get the same
    ratio.
    Having about 640 functions means 40sec compilation time. That's
    close to being a coffee break.
    Now I worked on a booking system (PHP) which has about 1200 PHP
    functions which would have meant 1min 20sec. That's a very rough
    approximation.
    Benchmark test script:
    http://mawercer.de/~marc/Test.hx
    Do you think splitting a larger project into pieces is enough to
    keep compilation time short?
    Or can urweb be made faster as well?
7) XHTML: does it make sense to think about encoding it differently -
    maybe something close to WASH style?
    html
      body onclick=".."
        script type="javascript" url="myscript.js"
      head
        h2 {["title"]}
    Of course this depends on indentation (like python, Haskell, ..) do.
    Its a faster to write and easier to read IMHO.
    Even if ur will never support this - would it be possible to use
    create a function taking a block of code (string) returning an ast
    which would be processed by ur instead?
8) does ur have a repository you I could clone ?
Marc Weber
    
    
More information about the Ur
mailing list