Mercurial > urweb
annotate demo/treeFun.ur @ 1430:36c0a1be3f5a
Allow debug and naughtyDebug in client-side code, implemented with alert
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Wed, 02 Mar 2011 18:35:03 -0500 |
parents | 311ca1ae715d |
children |
rev | line source |
---|---|
adamc@469 | 1 functor Make(M : sig |
adamc@469 | 2 type key |
adamc@469 | 3 con id :: Name |
adamc@469 | 4 con parent :: Name |
adamc@469 | 5 con cols :: {Type} |
adamc@469 | 6 constraint [id] ~ [parent] |
adamc@469 | 7 constraint [id, parent] ~ cols |
adamc@469 | 8 |
adamc@723 | 9 val key_inj : sql_injectable_prim key |
adamc@469 | 10 |
adamc@706 | 11 table tab : ([id = key, parent = option key] ++ cols) |
adamc@469 | 12 end) = struct |
adamc@469 | 13 |
adamc@469 | 14 open M |
adamc@469 | 15 |
adamc@469 | 16 fun tree (f : $([id = key, parent = option key] ++ cols) -> xbody) |
adamc@469 | 17 (root : option M.key) = |
adamc@469 | 18 let |
adamc@469 | 19 fun recurse (root : option key) = |
adamc@471 | 20 queryX' (SELECT * FROM tab WHERE {eqNullable' (SQL tab.{parent}) root}) |
adamc@469 | 21 (fn r => |
adamc@469 | 22 children <- recurse (Some r.Tab.id); |
adamc@469 | 23 return <xml> |
adamc@469 | 24 <li> {f r.Tab}</li> |
adamc@469 | 25 |
adamc@469 | 26 <ul> |
adamc@469 | 27 {children} |
adamc@469 | 28 </ul> |
adamc@469 | 29 </xml>) |
adamc@469 | 30 in |
adamc@469 | 31 recurse root |
adamc@469 | 32 end |
adamc@469 | 33 |
adamc@469 | 34 end |