diff options
Diffstat (limited to 'demo')
-rw-r--r-- | demo/more/conference.ur | 44 | ||||
-rw-r--r-- | demo/more/conference.urp | 1 | ||||
-rw-r--r-- | demo/more/dnat.ur | 42 | ||||
-rw-r--r-- | demo/more/dnat.urs | 8 |
4 files changed, 55 insertions, 40 deletions
diff --git a/demo/more/conference.ur b/demo/more/conference.ur index ca5d4a59..0488d52e 100644 --- a/demo/more/conference.ur +++ b/demo/more/conference.ur @@ -76,30 +76,6 @@ functor Make(M : sig val t = user end) - datatype dnat = O | S of source dnat - type dnatS = source dnat - - fun inc n = - v <- get n; - case v of - O => - n' <- source O; - set n (S n') - | S n => inc n - - fun dec n = - let - fun dec' last n = - v <- get n; - case v of - O => (case last of - None => return () - | Some n' => set n' O) - | S n' => dec' (Some n) n' - in - dec' None n - end - fun doRegister r = n <- oneRowE1 (SELECT COUNT( * ) AS N FROM user @@ -203,21 +179,9 @@ functor Make(M : sig return <xml><body> Thanks for submitting! </body></xml> - - fun authorBlanks n = - case n of - O => <xml/> - | S n => <xml> - <entry><b>Author:</b> <textbox{#Nam}/><br/></entry> - <dyn signal={authorBlanksS n}/> - </xml> - - and authorBlanksS n = - n <- signal n; - return (authorBlanks n) in me <- getLogin; - numAuthors <- source O; + numAuthors <- Dnat.zero; return <xml><body> <h1>Submit a Paper</h1> @@ -225,10 +189,10 @@ functor Make(M : sig <form> <b>Author:</b> {[me.Nam]}<br/> <subforms{#Authors}> - <dyn signal={authorBlanksS numAuthors}/> + {Dnat.render <xml><entry><b>Author:</b> <textbox{#Nam}/><br/></entry></xml> numAuthors} </subforms> - <button value="Add author" onclick={inc numAuthors}/><br/> - <button value="Remove author" onclick={dec numAuthors}/><br/> + <button value="Add author" onclick={Dnat.inc numAuthors}/><br/> + <button value="Remove author" onclick={Dnat.dec numAuthors}/><br/> <br/> {useMore (allWidgets M.paper M.paperFolder)} diff --git a/demo/more/conference.urp b/demo/more/conference.urp index 0fd67b8a..14181554 100644 --- a/demo/more/conference.urp +++ b/demo/more/conference.urp @@ -5,5 +5,6 @@ $/option $/list meta bulkEdit +dnat conference conferenceFields diff --git a/demo/more/dnat.ur b/demo/more/dnat.ur new file mode 100644 index 00000000..8d8095e7 --- /dev/null +++ b/demo/more/dnat.ur @@ -0,0 +1,42 @@ +datatype t' = O | S of source t' +type t = source t' + +val zero = source O + +fun inc n = + v <- get n; + case v of + O => + n' <- source O; + set n (S n') + | S n => inc n + +fun dec n = + let + fun dec' last n = + v <- get n; + case v of + O => (case last of + None => return () + | Some n' => set n' O) + | S n' => dec' (Some n) n' + in + dec' None n + end + +fun render [ctx] [inp] [[Body] ~ ctx] (xml : xml ([Body] ++ ctx) inp []) n = + let + fun render n = + n <- signal n; + return (render' n) + + and render' n = + case n of + O => <xml/> + | S n => <xml> + {xml} + <dyn signal={render n}/> + </xml> + in + <xml><dyn signal={render n}/></xml> + end diff --git a/demo/more/dnat.urs b/demo/more/dnat.urs new file mode 100644 index 00000000..2dd7e938 --- /dev/null +++ b/demo/more/dnat.urs @@ -0,0 +1,8 @@ +type t + +val zero : transaction t +val inc : t -> transaction unit +val dec : t -> transaction unit + +val render : ctx ::: {Unit} -> inp ::: {Type} -> [[Body] ~ ctx] => + xml ([Body] ++ ctx) inp [] -> t -> xml ([Body] ++ ctx) inp [] |