diff demo/metaform.ur @ 418:ad7e854a518c

Metaform demos, minus prose
author Adam Chlipala <adamc@hcoop.net>
date Thu, 23 Oct 2008 14:03:12 -0400
parents
children 6c4643880df5
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/demo/metaform.ur	Thu Oct 23 14:03:12 2008 -0400
@@ -0,0 +1,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