comparison tests/gform.ur @ 244:71bafe66dbe1

Laconic -> Ur
author Adam Chlipala <adamc@hcoop.net>
date Sun, 31 Aug 2008 08:32:18 -0400
parents tests/gform.lac@cc0bc756f66f
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 end
6
7 signature S' = sig
8 con rs :: {Unit}
9
10 val handler : $(stringify rs) -> page
11 val page : unit -> page
12 end
13
14 functor F (M : S) : S' where con rs = M.rs = struct
15 con rs = M.rs
16
17 val handler = fn x : $(stringify M.rs) => <html><body>
18 {fold [fn rs :: {Unit} => $(stringify rs) -> xml body [] []]
19 (fn nm :: Name => fn u :: Unit => fn rest :: {Unit} =>
20 fn f : $(stringify rest) -> xml body [] [] =>
21 fn x : $(stringify ([nm] ++ rest)) =>
22 <body><li> {cdata x.nm}</li> {f (x -- nm)}</body>)
23 (fn x => <body></body>)
24 [M.rs] x}
25 </body></html>
26
27 val page = fn () => <html><body>
28 <lform>
29 {fold [fn rs :: {Unit} => xml lform [] (stringify rs)]
30 (fn nm :: Name => fn u :: Unit => fn rest :: {Unit} =>
31 fn frag : xml lform [] (stringify rest) =>
32 <lform><li> <textbox{nm}/></li> {useMore frag}</lform>)
33 <lform></lform>
34 [rs]}
35
36 <submit action={handler}/>
37 </lform>
38 </body></html>
39 end
40
41 structure M = F(struct
42 con rs = [A, B, C]
43 end)
44
45 open M
46