summaryrefslogtreecommitdiff
path: root/tests/gform.lac
blob: e1b194c01a8434fe22ca13d992d10abf9f8624a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
con stringify = fold (fn nm :: Name => fn u :: Unit => fn t :: {Type} => [nm = string] ++ t) []

signature S = sig
        con rs :: {Unit}
end

signature S' = sig
        con rs :: {Unit}

        val handler : $(stringify rs) -> page
        val page : unit -> page
end

functor F (M : S) : S' where con rs = M.rs = struct
        con rs = M.rs

        val handler = fn x : $(stringify M.rs) => <html><body>
                {fold [fn rs :: {Unit} => $(stringify rs) -> xml body [] []]
                        (fn nm :: Name => fn u :: Unit => fn rest :: {Unit} =>
                                fn f : $(stringify rest) -> xml body [] [] =>
                                fn x : $(stringify ([nm] ++ rest)) =>
                                        <body><li> {cdata x.nm}</li> {f (x -- nm)}</body>)
                        (fn x => <body></body>)
                        [M.rs] x}
        </body></html>

        val page = fn () => <html><body>
                <lform>
                        {fold [fn rs :: {Unit} => xml lform [] (stringify rs)]
                                (fn nm :: Name => fn u :: Unit => fn rest :: {Unit} =>
                                        fn frag : xml lform [] (stringify rest) =>
                                                <lform><li> <textbox{nm}/></li> {useMore frag}</lform>)
                                <lform></lform>
                                [rs]}

                        <submit action={handler}/>
                </lform>
        </body></html>
end

structure M = F(struct
        con rs = [A, B, C]
end)

open M