summaryrefslogtreecommitdiff
path: root/demo/metaform.ur
blob: ae1197f48721cb8e8fac73abb1493102c6d0b2b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
functor Make (M : sig
                  con fs :: {Unit}
                  val names : $(mapUT string fs)
              end) = struct

    fun handler values = return <xml><body>
      {foldURX2 [string] [string] [body]
       (fn (nm :: Name) (rest :: {Unit}) [[nm] ~ rest] name value => <xml>
         <li> {[name]} = {[value]}</li>
       </xml>)
       [M.fs] M.names values}
    </body></xml>

    fun main () = return <xml><body>
      <form>
        {foldUR [string] [fn cols :: {Unit} => xml form [] (mapUT string cols)]
                (fn (nm :: Name) (rest :: {Unit}) [[nm] ~ rest] name
                                 (acc : xml form [] (mapUT string rest)) => <xml>
                                   <li> {[name]}: <textbox{nm}/></li>
                                   {useMore acc}
                                 </xml>)
                <xml/>
                [M.fs] M.names}
        <submit action={handler}/>
      </form>
    </body></xml>

end