adamc@56
|
1 type int
|
adamc@56
|
2 type float
|
adamc@56
|
3 type string
|
adamc@91
|
4
|
adamc@119
|
5 type unit = {}
|
adamc@119
|
6
|
adamc@186
|
7 datatype bool = False | True
|
adamc@186
|
8
|
adamc@91
|
9
|
adamc@203
|
10 (** SQL *)
|
adamc@203
|
11
|
adamc@203
|
12 con sql_table :: {Type} -> Type
|
adamc@203
|
13
|
adamc@204
|
14 (*** Queries *)
|
adamc@204
|
15
|
adamc@204
|
16 con sql_query :: {{Type}} -> Type
|
adamc@204
|
17
|
adamc@207
|
18 val sql_query : tables :: {({Type} * {Type})}
|
adamc@207
|
19 -> $(fold (fn nm => fn selected_unselected :: ({Type} * {Type}) => fn acc =>
|
adamc@207
|
20 [nm] ~ acc => selected_unselected.1 ~ selected_unselected.2 =>
|
adamc@207
|
21 [nm = sql_table (selected_unselected.1 ++ selected_unselected.2)] ++ acc) [] tables)
|
adamc@207
|
22 -> sql_query (fold (fn nm => fn selected_unselected :: ({Type} * {Type}) => fn acc => [nm] ~ acc =>
|
adamc@207
|
23 [nm = selected_unselected.1] ++ acc) [] tables)
|
adamc@204
|
24
|
adamc@203
|
25
|
adamc@203
|
26 (** XML *)
|
adamc@203
|
27
|
adamc@139
|
28 con tag :: {Type} -> {Unit} -> {Unit} -> {Type} -> {Type} -> Type
|
adamc@91
|
29
|
adamc@91
|
30
|
adamc@139
|
31 con xml :: {Unit} -> {Type} -> {Type} -> Type
|
adamc@141
|
32 val cdata : ctx ::: {Unit} -> use ::: {Type} -> string -> xml ctx use []
|
adamc@104
|
33 val tag : attrsGiven ::: {Type} -> attrsAbsent ::: {Type} -> attrsGiven ~ attrsAbsent
|
adamc@139
|
34 -> ctxOuter ::: {Unit} -> ctxInner ::: {Unit}
|
adamc@139
|
35 -> useOuter ::: {Type} -> useInner ::: {Type} -> useOuter ~ useInner
|
adamc@139
|
36 -> bindOuter ::: {Type} -> bindInner ::: {Type} -> bindOuter ~ bindInner
|
adamc@104
|
37 -> $attrsGiven
|
adamc@139
|
38 -> tag (attrsGiven ++ attrsAbsent) ctxOuter ctxInner useOuter bindOuter
|
adamc@139
|
39 -> xml ctxInner useInner bindInner
|
adamc@139
|
40 -> xml ctxOuter (useOuter ++ useInner) (bindOuter ++ bindInner)
|
adamc@140
|
41 val join : ctx ::: {Unit}
|
adamc@139
|
42 -> use1 ::: {Type} -> bind1 ::: {Type} -> bind2 ::: {Type}
|
adamc@139
|
43 -> use1 ~ bind1 -> bind1 ~ bind2
|
adamc@140
|
44 -> xml ctx use1 bind1
|
adamc@140
|
45 -> xml ctx (use1 ++ bind1) bind2
|
adamc@140
|
46 -> xml ctx use1 (bind1 ++ bind2)
|
adamc@148
|
47 val useMore : ctx ::: {Unit} -> use1 ::: {Type} -> use2 ::: {Type} -> bind ::: {Type}
|
adamc@148
|
48 -> use1 ~ use2
|
adamc@148
|
49 -> xml ctx use1 bind
|
adamc@148
|
50 -> xml ctx (use1 ++ use2) bind
|
adamc@91
|
51
|
adamc@110
|
52 con xhtml = xml [Html]
|
adamc@139
|
53 con page = xhtml [] []
|
adamc@110
|
54
|
adamc@204
|
55 (*** HTML details *)
|
adamc@204
|
56
|
adamc@140
|
57 con html = [Html]
|
adamc@140
|
58 con head = [Head]
|
adamc@140
|
59 con body = [Body]
|
adamc@141
|
60 con lform = [Body, LForm]
|
adamc@93
|
61
|
adamc@140
|
62 val head : unit -> tag [] html head [] []
|
adamc@140
|
63 val title : unit -> tag [] head [] [] []
|
adamc@110
|
64
|
adamc@140
|
65 val body : unit -> tag [] html body [] []
|
adamc@140
|
66 con bodyTag = fn attrs :: {Type} => ctx ::: {Unit} -> [Body] ~ ctx -> unit
|
adamc@140
|
67 -> tag attrs ([Body] ++ ctx) ([Body] ++ ctx) [] []
|
adamc@141
|
68 con bodyTagStandalone = fn attrs :: {Type} => ctx ::: {Unit} -> [Body] ~ ctx -> unit
|
adamc@141
|
69 -> tag attrs ([Body] ++ ctx) [] [] []
|
adamc@141
|
70
|
adamc@141
|
71 val br : bodyTagStandalone []
|
adamc@119
|
72
|
adamc@140
|
73 val p : bodyTag []
|
adamc@140
|
74 val b : bodyTag []
|
adamc@140
|
75 val i : bodyTag []
|
adamc@140
|
76 val font : bodyTag [Size = int, Face = string]
|
adamc@140
|
77
|
adamc@140
|
78 val h1 : bodyTag []
|
adamc@140
|
79 val li : bodyTag []
|
adamc@140
|
80
|
adamc@140
|
81 val a : bodyTag [Link = page]
|
adamc@140
|
82
|
adamc@141
|
83 val lform : ctx ::: {Unit} -> [Body] ~ ctx -> bind ::: {Type}
|
adamc@141
|
84 -> xml lform [] bind
|
adamc@141
|
85 -> xml ([Body] ++ ctx) [] []
|
adamc@153
|
86 con lformTag = fn ty :: Type => fn inner :: {Unit} => fn attrs :: {Type} =>
|
adamc@141
|
87 ctx ::: {Unit} -> [LForm] ~ ctx
|
adamc@141
|
88 -> nm :: Name -> unit
|
adamc@153
|
89 -> tag attrs ([LForm] ++ ctx) inner [] [nm = ty]
|
adamc@153
|
90 val textbox : lformTag string [] []
|
adamc@155
|
91 val password : lformTag string [] []
|
adamc@153
|
92 val ltextarea : lformTag string [] []
|
adamc@153
|
93
|
adamc@190
|
94 val checkbox : lformTag bool [] []
|
adamc@190
|
95
|
adamc@153
|
96 con radio = [Body, Radio]
|
adamc@153
|
97 val radio : lformTag string radio []
|
adamc@153
|
98 val radioOption : unit -> tag [Value = string] radio [] [] []
|
adamc@142
|
99
|
adamc@154
|
100 con select = [Select]
|
adamc@154
|
101 val lselect : lformTag string select []
|
adamc@154
|
102 val loption : unit -> tag [Value = string] select [] [] []
|
adamc@154
|
103
|
adamc@142
|
104 val submit : ctx ::: {Unit} -> [LForm] ~ ctx
|
adamc@142
|
105 -> use ::: {Type} -> unit
|
adamc@142
|
106 -> tag [Action = $use -> page] ([LForm] ++ ctx) ([LForm] ++ ctx) use []
|