annotate demo/crud2.ur @ 511:6d6222e045b0

crud1 compiles with new Reduce
author Adam Chlipala <adamc@hcoop.net>
date Wed, 26 Nov 2008 15:03:45 -0500
parents 0ce90d4d9ae7
children 6c4643880df5
rev   line source
adamc@422 1 table t : {Id : int, Nam : string, Ready : bool}
adamc@422 2
adamc@422 3 open Crud.Make(struct
adamc@422 4 val tab = t
adamc@422 5
adamc@422 6 val title = "Are you ready?"
adamc@422 7
adamc@422 8 val cols = {Nam = Crud.string "Name",
adamc@422 9 Ready = {Nam = "Ready",
adamc@422 10 Show = (fn b => if b then
adamc@422 11 <xml>Ready!</xml>
adamc@422 12 else
adamc@422 13 <xml>Not ready</xml>),
adamc@422 14 Widget = (fn (nm :: Name) => <xml>
adamc@422 15 <select{nm}>
adamc@422 16 <option>Ready</option>
adamc@422 17 <option>Not ready</option>
adamc@422 18 </select>
adamc@422 19 </xml>),
adamc@422 20 WidgetPopulated = (fn (nm :: Name) b => <xml>
adamc@422 21 <select{nm}>
adamc@422 22 <option selected={b}>Ready</option>
adamc@422 23 <option selected={not b}>Not ready</option>
adamc@422 24 </select>
adamc@422 25 </xml>),
adamc@422 26 Parse = (fn s =>
adamc@422 27 case s of
adamc@422 28 "Ready" => True
adamc@422 29 | "Not ready" => False
adamc@422 30 | _ => error <xml>Invalid ready/not ready</xml>),
adamc@422 31 Inject = _
adamc@422 32 }
adamc@422 33 }
adamc@422 34 end)