annotate demo/more/bid.ur @ 1022:4de35df3d545

Start of bidding implementation compiles
author Adam Chlipala <adamc@hcoop.net>
date Sat, 31 Oct 2009 15:51:50 -0400
parents
children e46227efcbba
rev   line source
adamc@1022 1 functor Make(M : Conference.INPUT) = struct
adamc@1022 2 open M
adamc@1022 3
adamc@1022 4 table bid : {User : userId, Paper : paperId, Interest : char}
adamc@1022 5 PRIMARY KEY (User, Paper)
adamc@1022 6
adamc@1022 7 table assignment : {User : userId, Paper : paperId}
adamc@1022 8 PRIMARY KEY (User, Paper)
adamc@1022 9
adamc@1022 10 fun isOnPc id =
adamc@1022 11 ro <- oneOrNoRows1 (SELECT user.OnPc
adamc@1022 12 FROM user
adamc@1022 13 WHERE user.Id = {[id]});
adamc@1022 14 return (case ro of
adamc@1022 15 None => False
adamc@1022 16 | Some r => r.OnPc)
adamc@1022 17
adamc@1022 18 val linksForPc =
adamc@1022 19 let
adamc@1022 20 fun bid () =
adamc@1022 21 me <- getLogin;
adamc@1022 22 return <xml>Bidding time!</xml>
adamc@1022 23 in
adamc@1022 24 <xml>
adamc@1022 25 <li> <a link={bid ()}>Bid on papers</a></li>
adamc@1022 26 </xml>
adamc@1022 27 end
adamc@1022 28
adamc@1022 29 con yourPaperTables = [Assignment = _]
adamc@1022 30 constraint [Paper] ~ yourPaperTables
adamc@1022 31 fun joinYourPaper [tabs] [paper] [[Paper] ~ tabs] [[Paper] ~ _] [tabs ~ yourPaperTables] [[Id] ~ paper]
adamc@1022 32 (fi : sql_from_items ([Paper = [Id = paperId] ++ paper] ++ tabs)) =
adamc@1022 33 sql_inner_join fi (sql_from_table [#Assignment] assignment) (WHERE Paper.Id = Assignment.Paper)
adamc@1022 34 end