annotate lib/basis.lig @ 232:a338da9d82f3

OFFSET
author Adam Chlipala <adamc@hcoop.net>
date Thu, 21 Aug 2008 16:03:45 -0400
parents eadeea528f75
children c466678af854
rev   line source
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@229 17 con sql_query1 :: {{Type}} -> {{Type}} -> Type
adamc@223 18 con sql_exp :: {{Type}} -> {{Type}} -> Type -> Type
adamc@204 19
adamc@223 20 con sql_subset :: {{Type}} -> {{Type}} -> Type
adamc@223 21 val sql_subset : keep_drop :: {({Type} * {Type})}
adamc@223 22 -> sql_subset
adamc@223 23 (fold (fn nm => fn fields :: ({Type} * {Type}) => fn acc =>
adamc@223 24 [nm] ~ acc => fields.1 ~ fields.2 =>
adamc@223 25 [nm = fields.1 ++ fields.2] ++ acc) [] keep_drop)
adamc@223 26 (fold (fn nm => fn fields :: ({Type} * {Type}) => fn acc =>
adamc@223 27 [nm] ~ acc =>
adamc@223 28 [nm = fields.1] ++ acc) [] keep_drop)
adamc@223 29 val sql_subset_all : tables :: {{Type}}
adamc@223 30 -> sql_subset tables tables
adamc@223 31
adamc@229 32 val sql_query1 : tables ::: {{Type}}
adamc@224 33 -> grouped ::: {{Type}}
adamc@223 34 -> selected ::: {{Type}}
adamc@223 35 -> {From : $(fold (fn nm => fn fields :: {Type} => fn acc =>
adamc@223 36 [nm] ~ acc => [nm = sql_table fields] ++ acc) [] tables),
adamc@223 37 Where : sql_exp tables [] bool,
adamc@224 38 GroupBy : sql_subset tables grouped,
adamc@224 39 Having : sql_exp grouped tables bool,
adamc@224 40 SelectFields : sql_subset grouped selected}
adamc@229 41 -> sql_query1 tables selected
adamc@229 42
adamc@229 43 type sql_relop
adamc@229 44 val sql_union : sql_relop
adamc@229 45 val sql_intersect : sql_relop
adamc@229 46 val sql_except : sql_relop
adamc@229 47 val sql_relop : sql_relop
adamc@229 48 -> tables1 ::: {{Type}}
adamc@229 49 -> tables2 ::: {{Type}}
adamc@229 50 -> selected ::: {{Type}}
adamc@229 51 -> sql_query1 tables1 selected -> sql_query1 tables2 selected -> sql_query1 selected selected
adamc@229 52
adamc@230 53 type sql_direction
adamc@230 54 val sql_asc : sql_direction
adamc@230 55 val sql_desc : sql_direction
adamc@230 56
adamc@230 57 con sql_order_by :: {{Type}} -> Type
adamc@230 58 val sql_order_by_Nil : tables :: {{Type}} -> sql_order_by tables
adamc@230 59 val sql_order_by_Cons : tables ::: {{Type}} -> t ::: Type
adamc@230 60 -> sql_exp tables [] t -> sql_order_by tables
adamc@230 61 -> sql_order_by tables
adamc@230 62
adamc@231 63 type sql_limit
adamc@231 64 val sql_no_limit : sql_limit
adamc@231 65 val sql_limit : int -> sql_limit
adamc@231 66
adamc@232 67 type sql_offset
adamc@232 68 val sql_no_offset : sql_offset
adamc@232 69 val sql_offset : int -> sql_offset
adamc@232 70
adamc@229 71 val sql_query : tables ::: {{Type}}
adamc@229 72 -> selected ::: {{Type}}
adamc@230 73 -> {Rows : sql_query1 tables selected,
adamc@231 74 OrderBy : sql_order_by tables,
adamc@232 75 Limit : sql_limit,
adamc@232 76 Offset : sql_offset}
adamc@223 77 -> sql_query selected
adamc@204 78
adamc@225 79 val sql_field : otherTabs ::: {{Type}} -> otherFields ::: {Type} -> fieldType ::: Type -> agg ::: {{Type}}
adamc@221 80 -> tab :: Name -> field :: Name
adamc@223 81 -> sql_exp ([tab = [field = fieldType] ++ otherFields] ++ otherTabs) agg fieldType
adamc@209 82
adamc@221 83 class sql_injectable
adamc@221 84 val sql_bool : sql_injectable bool
adamc@221 85 val sql_int : sql_injectable int
adamc@221 86 val sql_float : sql_injectable float
adamc@221 87 val sql_string : sql_injectable string
adamc@223 88 val sql_inject : tables ::: {{Type}} -> agg ::: {{Type}} -> t ::: Type -> t -> sql_injectable t -> sql_exp tables agg t
adamc@209 89
adamc@220 90 con sql_unary :: Type -> Type -> Type
adamc@220 91 val sql_not : sql_unary bool bool
adamc@223 92 val sql_unary : tables ::: {{Type}} -> agg ::: {{Type}} -> arg ::: Type -> res ::: Type
adamc@223 93 -> sql_unary arg res -> sql_exp tables agg arg -> sql_exp tables agg res
adamc@220 94
adamc@220 95 con sql_binary :: Type -> Type -> Type -> Type
adamc@220 96 val sql_and : sql_binary bool bool bool
adamc@220 97 val sql_or : sql_binary bool bool bool
adamc@223 98 val sql_binary : tables ::: {{Type}} -> agg ::: {{Type}} -> arg1 ::: Type -> arg2 ::: Type -> res ::: Type
adamc@223 99 -> sql_binary arg1 arg2 res -> sql_exp tables agg arg1 -> sql_exp tables agg arg2 -> sql_exp tables agg res
adamc@220 100
adamc@219 101 type sql_comparison
adamc@219 102 val sql_eq : sql_comparison
adamc@219 103 val sql_ne : sql_comparison
adamc@219 104 val sql_lt : sql_comparison
adamc@219 105 val sql_le : sql_comparison
adamc@219 106 val sql_gt : sql_comparison
adamc@219 107 val sql_ge : sql_comparison
adamc@219 108 val sql_comparison : sql_comparison
adamc@223 109 -> tables ::: {{Type}} -> agg ::: {{Type}} -> t ::: Type -> sql_exp tables agg t -> sql_exp tables agg t
adamc@223 110 -> sql_injectable t -> sql_exp tables agg bool
adamc@203 111
adamc@203 112 (** XML *)
adamc@203 113
adamc@139 114 con tag :: {Type} -> {Unit} -> {Unit} -> {Type} -> {Type} -> Type
adamc@91 115
adamc@91 116
adamc@139 117 con xml :: {Unit} -> {Type} -> {Type} -> Type
adamc@141 118 val cdata : ctx ::: {Unit} -> use ::: {Type} -> string -> xml ctx use []
adamc@104 119 val tag : attrsGiven ::: {Type} -> attrsAbsent ::: {Type} -> attrsGiven ~ attrsAbsent
adamc@139 120 -> ctxOuter ::: {Unit} -> ctxInner ::: {Unit}
adamc@139 121 -> useOuter ::: {Type} -> useInner ::: {Type} -> useOuter ~ useInner
adamc@139 122 -> bindOuter ::: {Type} -> bindInner ::: {Type} -> bindOuter ~ bindInner
adamc@104 123 -> $attrsGiven
adamc@139 124 -> tag (attrsGiven ++ attrsAbsent) ctxOuter ctxInner useOuter bindOuter
adamc@139 125 -> xml ctxInner useInner bindInner
adamc@139 126 -> xml ctxOuter (useOuter ++ useInner) (bindOuter ++ bindInner)
adamc@140 127 val join : ctx ::: {Unit}
adamc@139 128 -> use1 ::: {Type} -> bind1 ::: {Type} -> bind2 ::: {Type}
adamc@139 129 -> use1 ~ bind1 -> bind1 ~ bind2
adamc@140 130 -> xml ctx use1 bind1
adamc@140 131 -> xml ctx (use1 ++ bind1) bind2
adamc@140 132 -> xml ctx use1 (bind1 ++ bind2)
adamc@148 133 val useMore : ctx ::: {Unit} -> use1 ::: {Type} -> use2 ::: {Type} -> bind ::: {Type}
adamc@148 134 -> use1 ~ use2
adamc@148 135 -> xml ctx use1 bind
adamc@148 136 -> xml ctx (use1 ++ use2) bind
adamc@91 137
adamc@110 138 con xhtml = xml [Html]
adamc@139 139 con page = xhtml [] []
adamc@110 140
adamc@204 141 (*** HTML details *)
adamc@204 142
adamc@140 143 con html = [Html]
adamc@140 144 con head = [Head]
adamc@140 145 con body = [Body]
adamc@141 146 con lform = [Body, LForm]
adamc@93 147
adamc@140 148 val head : unit -> tag [] html head [] []
adamc@140 149 val title : unit -> tag [] head [] [] []
adamc@110 150
adamc@140 151 val body : unit -> tag [] html body [] []
adamc@140 152 con bodyTag = fn attrs :: {Type} => ctx ::: {Unit} -> [Body] ~ ctx -> unit
adamc@140 153 -> tag attrs ([Body] ++ ctx) ([Body] ++ ctx) [] []
adamc@141 154 con bodyTagStandalone = fn attrs :: {Type} => ctx ::: {Unit} -> [Body] ~ ctx -> unit
adamc@141 155 -> tag attrs ([Body] ++ ctx) [] [] []
adamc@141 156
adamc@141 157 val br : bodyTagStandalone []
adamc@119 158
adamc@140 159 val p : bodyTag []
adamc@140 160 val b : bodyTag []
adamc@140 161 val i : bodyTag []
adamc@140 162 val font : bodyTag [Size = int, Face = string]
adamc@140 163
adamc@140 164 val h1 : bodyTag []
adamc@140 165 val li : bodyTag []
adamc@140 166
adamc@140 167 val a : bodyTag [Link = page]
adamc@140 168
adamc@141 169 val lform : ctx ::: {Unit} -> [Body] ~ ctx -> bind ::: {Type}
adamc@141 170 -> xml lform [] bind
adamc@141 171 -> xml ([Body] ++ ctx) [] []
adamc@153 172 con lformTag = fn ty :: Type => fn inner :: {Unit} => fn attrs :: {Type} =>
adamc@141 173 ctx ::: {Unit} -> [LForm] ~ ctx
adamc@141 174 -> nm :: Name -> unit
adamc@153 175 -> tag attrs ([LForm] ++ ctx) inner [] [nm = ty]
adamc@153 176 val textbox : lformTag string [] []
adamc@155 177 val password : lformTag string [] []
adamc@153 178 val ltextarea : lformTag string [] []
adamc@153 179
adamc@190 180 val checkbox : lformTag bool [] []
adamc@190 181
adamc@153 182 con radio = [Body, Radio]
adamc@153 183 val radio : lformTag string radio []
adamc@153 184 val radioOption : unit -> tag [Value = string] radio [] [] []
adamc@142 185
adamc@154 186 con select = [Select]
adamc@154 187 val lselect : lformTag string select []
adamc@154 188 val loption : unit -> tag [Value = string] select [] [] []
adamc@154 189
adamc@142 190 val submit : ctx ::: {Unit} -> [LForm] ~ ctx
adamc@142 191 -> use ::: {Type} -> unit
adamc@142 192 -> tag [Action = $use -> page] ([LForm] ++ ctx) ([LForm] ++ ctx) use []