annotate demo/tree.ur @ 731:e0dd85ea58e1

Label exported symbols by effect-ness; factor out some common datatypes
author Adam Chlipala <adamc@hcoop.net>
date Thu, 16 Apr 2009 14:49:25 -0400
parents 1db127b245ed
children 5819fb63c93a
rev   line source
adamc@471 1 sequence s
adamc@469 2 table t : { Id : int, Parent : option int, Nam : string }
adamc@715 3 PRIMARY KEY Id,
adamc@715 4 CONSTRAINT F FOREIGN KEY Parent REFERENCES t (Id) ON DELETE CASCADE
adamc@469 5
adamc@469 6 open TreeFun.Make(struct
adamc@469 7 val tab = t
adamc@469 8 end)
adamc@469 9
adamc@469 10 fun row r = <xml>
adamc@471 11 #{[r.Id]}: {[r.Nam]} <a link={del r.Id}>[Delete]</a>
adamc@471 12
adamc@471 13 <form>
adamc@471 14 Add child: <textbox{#Nam}/> <submit action={add (Some r.Id)}/>
adamc@471 15 </form>
adamc@469 16 </xml>
adamc@469 17
adamc@471 18 and main () =
adamc@469 19 xml <- tree row None;
adamc@469 20 return <xml><body>
adamc@469 21 {xml}
adamc@471 22
adamc@471 23 <form>
adamc@471 24 Add a top-level node: <textbox{#Nam}/> <submit action={add None}/>
adamc@471 25 </form>
adamc@469 26 </body></xml>
adamc@471 27
adamc@471 28 and add parent r =
adamc@471 29 id <- nextval s;
adamc@471 30 dml (INSERT INTO t (Id, Parent, Nam) VALUES ({[id]}, {[parent]}, {[r.Nam]}));
adamc@471 31 main ()
adamc@471 32
adamc@471 33 and del id =
adamc@471 34 dml (DELETE FROM t WHERE Id = {[id]});
adamc@471 35 main ()