annotate demo/treeFun.ur @ 518:685d232bd1a5

Remove some isUnitCon cases
author Adam Chlipala <adamc@hcoop.net>
date Thu, 27 Nov 2008 11:17:56 -0500
parents 20fab0e96217
children 1fb318c17546
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@469 9 val key_inj : sql_injectable key
adamc@469 10 val option_key_inj : sql_injectable (option key)
adamc@469 11
adamc@469 12 table tab : [id = key, parent = option key] ++ cols
adamc@469 13 end) = struct
adamc@469 14
adamc@469 15 open M
adamc@469 16
adamc@469 17 fun tree (f : $([id = key, parent = option key] ++ cols) -> xbody)
adamc@469 18 (root : option M.key) =
adamc@469 19 let
adamc@469 20 fun recurse (root : option key) =
adamc@471 21 queryX' (SELECT * FROM tab WHERE {eqNullable' (SQL tab.{parent}) root})
adamc@469 22 (fn r =>
adamc@469 23 children <- recurse (Some r.Tab.id);
adamc@469 24 return <xml>
adamc@469 25 <li> {f r.Tab}</li>
adamc@469 26
adamc@469 27 <ul>
adamc@469 28 {children}
adamc@469 29 </ul>
adamc@469 30 </xml>)
adamc@469 31 in
adamc@469 32 recurse root
adamc@469 33 end
adamc@469 34
adamc@469 35 end