Mercurial > urweb
diff demo/view.ur @ 778:7b47fc964a0f
view demo
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Sun, 03 May 2009 15:13:00 -0400 |
parents | |
children | 669ac5e9a69e |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/demo/view.ur Sun May 03 15:13:00 2009 -0400 @@ -0,0 +1,25 @@ +table t : { A : int } +view v = SELECT t.A AS A FROM t WHERE t.A > 7 + +fun list (u ::: Type) (_ : fieldsOf u [A = int]) (title : string) (x : u) = + xml <- queryX (SELECT * FROM x) + (fn r : {X : {A : int}} => <xml><li>{[r.X.A]}</li></xml>); + return <xml> + <h2>{[title]}</h2> + <ul>{xml}</ul> + </xml> + +fun main () = + listT <- list "T" t; + listV <- list "V" v; + return <xml><body> + {listT} + {listV} + <br/> + + <form>Insert: <textbox{#A}/> <submit action={ins}/></form> + </body></xml> + +and ins r = + dml (INSERT INTO t (A) VALUES ({[readError r.A]})); + main ()