annotate tests/gformText.ur @ 866:03e7f111fe99

Start of multi-DBMS support
author Adam Chlipala <adamc@hcoop.net>
date Sun, 28 Jun 2009 13:49:32 -0400
parents 71bafe66dbe1
children
rev   line source
adamc@151 1 con stringify = fold (fn nm :: Name => fn u :: Unit => fn t :: {Type} => [nm = string] ++ t) []
adamc@151 2
adamc@151 3 signature S = sig
adamc@151 4 con rs :: {Unit}
adamc@151 5 val names : $(stringify rs)
adamc@151 6 end
adamc@151 7
adamc@151 8 signature S' = sig
adamc@151 9 con rs :: {Unit}
adamc@151 10
adamc@151 11 val handler : $(stringify rs) -> page
adamc@151 12 val page : unit -> page
adamc@151 13 end
adamc@151 14
adamc@151 15 functor F (M : S) : S' where con rs = M.rs = struct
adamc@151 16 con rs = M.rs
adamc@151 17
adamc@151 18 val handler = fn x : $(stringify M.rs) => <html><body>
adamc@151 19 {fold [fn rs :: {Unit} => $(stringify rs) -> $(stringify rs) -> xml body [] []]
adamc@151 20 (fn nm :: Name => fn u :: Unit => fn rest :: {Unit} =>
adamc@151 21 fn f : $(stringify rest) -> $(stringify rest) -> xml body [] [] =>
adamc@151 22 fn names : $(stringify ([nm] ++ rest)) =>
adamc@151 23 fn x : $(stringify ([nm] ++ rest)) =>
adamc@151 24 <body><li> {cdata names.nm}: {cdata x.nm}</li> {f (names -- nm) (x -- nm)}</body>)
adamc@151 25 (fn names => fn x => <body></body>)
adamc@151 26 [M.rs] M.names x}
adamc@151 27 </body></html>
adamc@151 28
adamc@151 29 val page = fn () => <html><body>
adamc@151 30 <lform>
adamc@151 31 {fold [fn rs :: {Unit} => xml lform [] (stringify rs)]
adamc@151 32 (fn nm :: Name => fn u :: Unit => fn rest :: {Unit} =>
adamc@151 33 fn frag : xml lform [] (stringify rest) =>
adamc@151 34 <lform><li> <textbox{nm}/></li> {useMore frag}</lform>)
adamc@151 35 <lform></lform>
adamc@151 36 [rs]}
adamc@151 37
adamc@151 38 <submit action={handler}/>
adamc@151 39 </lform>
adamc@151 40 </body></html>
adamc@151 41 end
adamc@151 42
adamc@151 43 structure M = F(struct
adamc@151 44 con rs = [A, B, C]
adamc@151 45
adamc@151 46 val names = {A = "A", B = "B", C = "C"}
adamc@151 47 end)
adamc@151 48
adamc@151 49 open M
adamc@151 50