comparison tests/gformText.ur @ 244:71bafe66dbe1

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