summaryrefslogtreecommitdiff
path: root/demo
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2008-10-23 14:03:12 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2008-10-23 14:03:12 -0400
commita4a697ab04bac663206a54292d73f67ca895c243 (patch)
tree65ced70d644fa88a41a2270c9e5351cca303914c /demo
parent2e606b03c8dbc594610e62ac260145ac26ebc699 (diff)
Metaform demos, minus prose
Diffstat (limited to 'demo')
-rw-r--r--demo/metaform.ur28
-rw-r--r--demo/metaform.urs6
-rw-r--r--demo/metaform1.ur3
-rw-r--r--demo/metaform1.urp3
-rw-r--r--demo/metaform1.urs1
-rw-r--r--demo/metaform2.ur12
-rw-r--r--demo/metaform2.urp3
-rw-r--r--demo/metaform2.urs1
-rw-r--r--demo/prose4
9 files changed, 61 insertions, 0 deletions
diff --git a/demo/metaform.ur b/demo/metaform.ur
new file mode 100644
index 00000000..ae1197f4
--- /dev/null
+++ b/demo/metaform.ur
@@ -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
diff --git a/demo/metaform.urs b/demo/metaform.urs
new file mode 100644
index 00000000..7a3fa62e
--- /dev/null
+++ b/demo/metaform.urs
@@ -0,0 +1,6 @@
+functor Make (M : sig
+ con fs :: {Unit}
+ val names : $(mapUT string fs)
+ end) : sig
+ val main : unit -> transaction page
+end
diff --git a/demo/metaform1.ur b/demo/metaform1.ur
new file mode 100644
index 00000000..c6a4664d
--- /dev/null
+++ b/demo/metaform1.ur
@@ -0,0 +1,3 @@
+open Metaform.Make(struct
+ val names = {A = "Tic", B = "Tac", C = "Toe"}
+ end)
diff --git a/demo/metaform1.urp b/demo/metaform1.urp
new file mode 100644
index 00000000..7f04b9b7
--- /dev/null
+++ b/demo/metaform1.urp
@@ -0,0 +1,3 @@
+
+metaform
+metaform1
diff --git a/demo/metaform1.urs b/demo/metaform1.urs
new file mode 100644
index 00000000..6ac44e0b
--- /dev/null
+++ b/demo/metaform1.urs
@@ -0,0 +1 @@
+val main : unit -> transaction page
diff --git a/demo/metaform2.ur b/demo/metaform2.ur
new file mode 100644
index 00000000..430a42f0
--- /dev/null
+++ b/demo/metaform2.ur
@@ -0,0 +1,12 @@
+structure MM = Metaform.Make(struct
+ val names = {X = "x", Y = "y"}
+ end)
+
+fun diversion () = return <xml><body>
+ Welcome to the diversion.
+</body></xml>
+
+fun main () = return <xml><body>
+ <li> <a link={diversion ()}>See something shiny!</a></li>
+ <li> <a link={MM.main ()}>Fill out a form!</a></li>
+</body></xml>
diff --git a/demo/metaform2.urp b/demo/metaform2.urp
new file mode 100644
index 00000000..debc0448
--- /dev/null
+++ b/demo/metaform2.urp
@@ -0,0 +1,3 @@
+
+metaform
+metaform2
diff --git a/demo/metaform2.urs b/demo/metaform2.urs
new file mode 100644
index 00000000..6ac44e0b
--- /dev/null
+++ b/demo/metaform2.urs
@@ -0,0 +1 @@
+val main : unit -> transaction page
diff --git a/demo/prose b/demo/prose
index 19e9df0f..4fb07673 100644
--- a/demo/prose
+++ b/demo/prose
@@ -104,3 +104,7 @@ An unusual part of the third argument is the syntax <tt>[t1 ~ t2]</tt> within a
tcSum.urp
<p>It's easy to adapt the last example to use type classes, such that we can sum the fields of records based on any numeric type.</p>
+
+metaform1.urp
+
+metaform2.urp