summaryrefslogtreecommitdiff
path: root/demo
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2008-11-04 09:33:35 -0500
committerGravatar Adam Chlipala <adamc@hcoop.net>2008-11-04 09:33:35 -0500
commiteaa8aa9f310d95a31747ea4c81ee1013c1734a7d (patch)
treee40f2a8767966c59e146479de02ec297958fc3c3 /demo
parenteb3c0058fd7e3b763d20fa25104493fe9dfb2d18 (diff)
Nested demo
Diffstat (limited to 'demo')
-rw-r--r--demo/crud.ur8
-rw-r--r--demo/nested.ur62
-rw-r--r--demo/nested.urp2
-rw-r--r--demo/nested.urs1
-rw-r--r--demo/prose4
5 files changed, 73 insertions, 4 deletions
diff --git a/demo/crud.ur b/demo/crud.ur
index 77fccf16..ee6a95f6 100644
--- a/demo/crud.ur
+++ b/demo/crud.ur
@@ -100,9 +100,9 @@ functor Make(M : sig
sql_exp [] [] [] t.1) cols)]
(fn (nm :: Name) (t :: (Type * Type)) (rest :: {(Type * Type)})
[[nm] ~ rest] =>
- fn input col acc => acc with nm = @sql_inject col.Inject (col.Parse input))
+ fn input col acc => acc ++ {nm = @sql_inject col.Inject (col.Parse input)})
{} [M.cols] inputs M.cols
- with #Id = (SQL {id})));
+ ++ {Id = (SQL {id})}));
ls <- list ();
return <xml><body>
<p>Inserted with ID {[id]}.</p>
@@ -119,8 +119,8 @@ functor Make(M : sig
[] [] t.1) cols)]
(fn (nm :: Name) (t :: (Type * Type)) (rest :: {(Type * Type)})
[[nm] ~ rest] =>
- fn input col acc => acc with nm =
- @sql_inject col.Inject (col.Parse input))
+ fn input col acc => acc ++ {nm =
+ @sql_inject col.Inject (col.Parse input)})
{} [M.cols] inputs M.cols)
tab (WHERE T.Id = {id}));
ls <- list ();
diff --git a/demo/nested.ur b/demo/nested.ur
new file mode 100644
index 00000000..31c9e1e8
--- /dev/null
+++ b/demo/nested.ur
@@ -0,0 +1,62 @@
+fun pageA () = return <xml>
+ <head>
+ <title>A</title>
+ </head>
+ <body>
+ <form>
+ <table>
+ <tr>
+ <td>Forename:</td>
+ <td><textbox{#Forename}/></td>
+ </tr>
+ <tr>
+ <td>Enter a Surname?</td>
+ <td><checkbox{#EnterSurname}/></td>
+ </tr>
+ </table>
+ <submit action={fromA} />
+ </form>
+ </body>
+</xml>
+
+and fromA r =
+ let
+ val forename = r.Forename
+
+ fun pageB () = return <xml>
+ <head>
+ <title>B</title>
+ </head>
+ <body>
+ <form>
+ Surname:
+ <textbox{#Surname}/>
+ <submit action={pageC'} />
+ </form>
+ <a link={pageA ()}>Previous</a>
+ </body>
+ </xml>
+
+ and pageC' r = pageC (Some r.Surname)
+
+ and pageC surname = return <xml>
+ <head>
+ <title>C</title>
+ </head>
+ <body>
+ <p>Hello {[forename]}{case surname of
+ None => <xml/>
+ | Some s => <xml> {[s]}</xml>}</p>
+ {case surname of
+ None => <xml><a link={pageA ()}>Previous</a></xml>
+ | Some _ => <xml><a link={pageB ()}>Previous</a></xml>}
+ </body>
+ </xml>
+ in
+ if r.EnterSurname then
+ pageB ()
+ else
+ pageC None
+ end
+
+val main = pageA
diff --git a/demo/nested.urp b/demo/nested.urp
new file mode 100644
index 00000000..179014dc
--- /dev/null
+++ b/demo/nested.urp
@@ -0,0 +1,2 @@
+
+nested
diff --git a/demo/nested.urs b/demo/nested.urs
new file mode 100644
index 00000000..6ac44e0b
--- /dev/null
+++ b/demo/nested.urs
@@ -0,0 +1 @@
+val main : unit -> transaction page
diff --git a/demo/prose b/demo/prose
index 3b9d9ebb..06c47722 100644
--- a/demo/prose
+++ b/demo/prose
@@ -54,6 +54,10 @@ form.urp
<p>Here we see a basic form. The type system tracks which form inputs we include, and it enforces that the form handler function expects a record containing exactly those fields, with exactly the proper types.</p>
+nested.urp
+
+<p>Here is an implementation of the tiny challenge problem from <a href="http://www.accursoft.co.uk/web/">this web framework comparison</a>. Using nested function definitions, it is easy to persist state across clicks.</p>
+
listShop.urp
<p>This example shows off algebraic datatypes, parametric polymorphism, and functors.</p>