annotate lib/ur/basis.urs @ 775:a8bdd5a0d9b0

css demo
author Adam Chlipala <adamc@hcoop.net>
date Sun, 03 May 2009 12:36:25 -0400
parents c125df6fabfc
children 87a7702d681d
rev   line source
adamc@56 1 type int
adamc@56 2 type float
adamc@56 3 type string
adamc@436 4 type time
adamc@737 5 type blob
adamc@91 6
adamc@119 7 type unit = {}
adamc@119 8
adamc@186 9 datatype bool = False | True
adamc@186 10
adamc@288 11 datatype option t = None | Some of t
adamc@284 12
adamc@757 13 datatype list t = Nil | Cons of t * list t
adamc@757 14
adamc@91 15
adamc@256 16 (** Basic type classes *)
adamc@256 17
adamc@256 18 class eq
adamc@256 19 val eq : t ::: Type -> eq t -> t -> t -> bool
adamc@257 20 val ne : t ::: Type -> eq t -> t -> t -> bool
adamc@256 21 val eq_int : eq int
adamc@394 22 val eq_float : eq float
adamc@256 23 val eq_string : eq string
adamc@256 24 val eq_bool : eq bool
adamc@437 25 val eq_time : eq time
adamc@422 26 val mkEq : t ::: Type -> (t -> t -> bool) -> eq t
adamc@256 27
adamc@389 28 class num
adamc@417 29 val zero : t ::: Type -> num t -> t
adamc@389 30 val neg : t ::: Type -> num t -> t -> t
adamc@389 31 val plus : t ::: Type -> num t -> t -> t -> t
adamc@389 32 val minus : t ::: Type -> num t -> t -> t -> t
adamc@389 33 val times : t ::: Type -> num t -> t -> t -> t
adamc@775 34 val divide : t ::: Type -> num t -> t -> t -> t
adamc@389 35 val mod : t ::: Type -> num t -> t -> t -> t
adamc@389 36 val num_int : num int
adamc@390 37 val num_float : num float
adamc@389 38
adamc@391 39 class ord
adamc@391 40 val lt : t ::: Type -> ord t -> t -> t -> bool
adamc@391 41 val le : t ::: Type -> ord t -> t -> t -> bool
adamc@391 42 val gt : t ::: Type -> ord t -> t -> t -> bool
adamc@391 43 val ge : t ::: Type -> ord t -> t -> t -> bool
adamc@391 44 val ord_int : ord int
adamc@394 45 val ord_float : ord float
adamc@394 46 val ord_string : ord string
adamc@394 47 val ord_bool : ord bool
adamc@437 48 val ord_time : ord time
adamc@391 49
adamc@256 50
adamc@283 51 (** String operations *)
adamc@283 52
adamc@283 53 val strcat : string -> string -> string
adamc@283 54
adamc@286 55 class show
adamc@286 56 val show : t ::: Type -> show t -> t -> string
adamc@286 57 val show_int : show int
adamc@286 58 val show_float : show float
adamc@286 59 val show_string : show string
adamc@286 60 val show_bool : show bool
adamc@436 61 val show_time : show time
adamc@452 62 val mkShow : t ::: Type -> (t -> string) -> show t
adamc@286 63
adamc@290 64 class read
adamc@290 65 val read : t ::: Type -> read t -> string -> option t
adamc@292 66 val readError : t ::: Type -> read t -> string -> t
adamc@292 67 (* [readError] calls [error] if the input is malformed. *)
adamc@290 68 val read_int : read int
adamc@290 69 val read_float : read float
adamc@290 70 val read_string : read string
adamc@290 71 val read_bool : read bool
adamc@436 72 val read_time : read time
adamc@288 73
adamc@283 74
adamc@564 75 (** * Monads *)
adamc@564 76
adamc@711 77 class monad :: (Type -> Type) -> Type
adamc@564 78 val return : m ::: (Type -> Type) -> t ::: Type
adamc@564 79 -> monad m
adamc@564 80 -> t -> m t
adamc@564 81 val bind : m ::: (Type -> Type) -> t1 ::: Type -> t2 ::: Type
adamc@564 82 -> monad m
adamc@564 83 -> m t1 -> (t1 -> m t2)
adamc@564 84 -> m t2
adamc@564 85
adamc@456 86 con transaction :: Type -> Type
adamc@564 87 val transaction_monad : monad transaction
adamc@456 88
adamc@565 89 con source :: Type -> Type
adamc@565 90 val source : t ::: Type -> t -> transaction (source t)
adamc@575 91 val set : t ::: Type -> source t -> t -> transaction unit
adamc@601 92 val get : t ::: Type -> source t -> transaction t
adamc@565 93
adamc@565 94 con signal :: Type -> Type
adamc@565 95 val signal_monad : monad signal
adamc@565 96 val signal : t ::: Type -> source t -> signal t
adamc@456 97
adamc@456 98
adamc@456 99 (** HTTP operations *)
adamc@456 100
adamc@456 101 val requestHeader : string -> transaction (option string)
adamc@456 102
adamc@459 103 con http_cookie :: Type -> Type
adamc@459 104 val getCookie : t ::: Type -> http_cookie t -> transaction (option t)
adamc@459 105 val setCookie : t ::: Type -> http_cookie t -> t -> transaction unit
adamc@459 106
adamc@456 107
adamc@566 108 (** JavaScript-y gadgets *)
adamc@566 109
adamc@566 110 val alert : string -> transaction unit
adamc@694 111 val spawn : transaction unit -> transaction unit
adamc@695 112 val sleep : int -> transaction unit
adamc@566 113
adamc@566 114
adamc@678 115 (** Channels *)
adamc@678 116
adamc@678 117 con channel :: Type -> Type
adamc@678 118 val channel : t ::: Type -> transaction (channel t)
adamc@678 119 val send : t ::: Type -> channel t -> t -> transaction unit
adamc@678 120 val recv : t ::: Type -> channel t -> transaction t
adamc@678 121
adamc@682 122 type client
adamc@682 123 val self : transaction client
adamc@682 124
adamc@678 125
adamc@203 126 (** SQL *)
adamc@203 127
adamc@705 128 con sql_table :: {Type} -> {{Unit}} -> Type
adamc@753 129 con sql_view :: {Type} -> Type
adamc@753 130
adamc@753 131 class fieldsOf :: Type -> {Type} -> Type
adamc@753 132 val fieldsOf_table : fs ::: {Type} -> keys ::: {{Unit}}
adamc@753 133 -> fieldsOf (sql_table fs keys) fs
adamc@753 134 val fieldsOf_view : fs ::: {Type}
adamc@753 135 -> fieldsOf (sql_view fs) fs
adamc@203 136
adamc@704 137 (*** Constraints *)
adamc@704 138
adamc@707 139 (**** Primary keys *)
adamc@707 140
adamc@707 141 class sql_injectable_prim
adamc@707 142 val sql_bool : sql_injectable_prim bool
adamc@707 143 val sql_int : sql_injectable_prim int
adamc@707 144 val sql_float : sql_injectable_prim float
adamc@707 145 val sql_string : sql_injectable_prim string
adamc@707 146 val sql_time : sql_injectable_prim time
adamc@737 147 val sql_blob : sql_injectable_prim blob
adamc@707 148 val sql_channel : t ::: Type -> sql_injectable_prim (channel t)
adamc@707 149 val sql_client : sql_injectable_prim client
adamc@707 150
adamc@707 151 con primary_key :: {Type} -> {{Unit}} -> Type
adamc@707 152 val no_primary_key : fs ::: {Type} -> primary_key fs []
adamc@707 153 val primary_key : rest ::: {Type} -> t ::: Type -> key1 :: Name -> keys :: {Type}
adamc@707 154 -> [[key1] ~ keys] => [[key1 = t] ++ keys ~ rest]
adamc@707 155 => $([key1 = sql_injectable_prim t] ++ map sql_injectable_prim keys)
adamc@707 156 -> primary_key ([key1 = t] ++ keys ++ rest)
adamc@707 157 [Pkey = [key1] ++ map (fn _ => ()) keys]
adamc@707 158
adamc@707 159 (**** Other constraints *)
adamc@707 160
adamc@705 161 con sql_constraints :: {Type} -> {{Unit}} -> Type
adamc@705 162 (* Arguments: column types, uniqueness implications of constraints *)
adamc@704 163
adamc@705 164 con sql_constraint :: {Type} -> {Unit} -> Type
adamc@704 165
adamc@705 166 val no_constraint : fs ::: {Type} -> sql_constraints fs []
adamc@705 167 val one_constraint : fs ::: {Type} -> unique ::: {Unit} -> name :: Name
adamc@705 168 -> sql_constraint fs unique
adamc@705 169 -> sql_constraints fs [name = unique]
adamc@705 170 val join_constraints : fs ::: {Type}
adamc@705 171 -> uniques1 ::: {{Unit}} -> uniques2 ::: {{Unit}} -> [uniques1 ~ uniques2]
adamc@705 172 => sql_constraints fs uniques1 -> sql_constraints fs uniques2
adamc@705 173 -> sql_constraints fs (uniques1 ++ uniques2)
adamc@705 174
adamc@709 175
adamc@705 176 val unique : rest ::: {Type} -> t ::: Type -> unique1 :: Name -> unique :: {Type}
adamc@705 177 -> [[unique1] ~ unique] => [[unique1 = t] ++ unique ~ rest]
adamc@705 178 => sql_constraint ([unique1 = t] ++ unique ++ rest) ([unique1] ++ map (fn _ => ()) unique)
adamc@704 179
adamc@712 180 class linkable :: Type -> Type -> Type
adamc@712 181 val linkable_same : t ::: Type -> linkable t t
adamc@712 182 val linkable_from_nullable : t ::: Type -> linkable (option t) t
adamc@712 183 val linkable_to_nullable : t ::: Type -> linkable t (option t)
adamc@712 184
adamc@709 185 con matching :: {Type} -> {Type} -> Type
adamc@709 186 val mat_nil : matching [] []
adamc@712 187 val mat_cons : t1 ::: Type -> rest1 ::: {Type} -> t2 ::: Type -> rest2 ::: {Type}
adamc@709 188 -> nm1 :: Name -> nm2 :: Name
adamc@709 189 -> [[nm1] ~ rest1] => [[nm2] ~ rest2]
adamc@712 190 => linkable t1 t2
adamc@712 191 -> matching rest1 rest2
adamc@712 192 -> matching ([nm1 = t1] ++ rest1) ([nm2 = t2] ++ rest2)
adamc@709 193
adamc@709 194 con propagation_mode :: {Type} -> Type
adamc@709 195 val restrict : fs ::: {Type} -> propagation_mode fs
adamc@709 196 val cascade : fs ::: {Type} -> propagation_mode fs
adamc@709 197 val no_action : fs ::: {Type} -> propagation_mode fs
adamc@709 198 val set_null : fs ::: {Type} -> propagation_mode (map option fs)
adamc@709 199
adamc@709 200
adamc@709 201 val foreign_key : mine1 ::: Name -> t ::: Type -> mine ::: {Type} -> munused ::: {Type}
adamc@709 202 -> foreign ::: {Type} -> funused ::: {Type}
adamc@709 203 -> nm ::: Name -> uniques ::: {{Unit}}
adamc@709 204 -> [[mine1] ~ mine] => [[mine1 = t] ++ mine ~ munused]
adamc@709 205 => [foreign ~ funused] => [[nm] ~ uniques]
adamc@709 206 => matching ([mine1 = t] ++ mine) foreign
adamc@709 207 -> sql_table (foreign ++ funused) ([nm = map (fn _ => ()) foreign] ++ uniques)
adamc@709 208 -> {OnDelete : propagation_mode ([mine1 = t] ++ mine),
adamc@709 209 OnUpdate : propagation_mode ([mine1 = t] ++ mine)}
adamc@709 210 -> sql_constraint ([mine1 = t] ++ mine ++ munused) []
adamc@709 211
adamc@714 212 con sql_exp :: {{Type}} -> {{Type}} -> {Type} -> Type -> Type
adamc@714 213
adamc@714 214 val check : fs ::: {Type}
adamc@714 215 -> sql_exp [] [] fs bool
adamc@714 216 -> sql_constraint fs []
adamc@714 217
adamc@714 218
adamc@704 219
adamc@204 220 (*** Queries *)
adamc@204 221
adamc@233 222 con sql_query :: {{Type}} -> {Type} -> Type
adamc@233 223 con sql_query1 :: {{Type}} -> {{Type}} -> {Type} -> Type
adamc@204 224
adamc@223 225 con sql_subset :: {{Type}} -> {{Type}} -> Type
adamc@223 226 val sql_subset : keep_drop :: {({Type} * {Type})}
adamc@354 227 -> sql_subset
adamc@621 228 (map (fn fields :: ({Type} * {Type}) => fields.1 ++ fields.2) keep_drop)
adamc@621 229 (map (fn fields :: ({Type} * {Type}) => fields.1) keep_drop)
adamc@354 230 val sql_subset_all : tables :: {{Type}} -> sql_subset tables tables
adamc@223 231
adamc@748 232 con sql_from_items :: {{Type}} -> Type
adamc@748 233
adamc@753 234 val sql_from_table : t ::: Type -> fs ::: {Type}
adamc@753 235 -> fieldsOf t fs -> name :: Name
adamc@753 236 -> t -> sql_from_items [name = fs]
adamc@748 237 val sql_from_comma : tabs1 ::: {{Type}} -> tabs2 ::: {{Type}}
adamc@748 238 -> [tabs1 ~ tabs2]
adamc@748 239 => sql_from_items tabs1 -> sql_from_items tabs2
adamc@748 240 -> sql_from_items (tabs1 ++ tabs2)
adamc@749 241 val sql_inner_join : tabs1 ::: {{Type}} -> tabs2 ::: {{Type}}
adamc@749 242 -> [tabs1 ~ tabs2]
adamc@749 243 => sql_from_items tabs1 -> sql_from_items tabs2
adamc@749 244 -> sql_exp (tabs1 ++ tabs2) [] [] bool
adamc@749 245 -> sql_from_items (tabs1 ++ tabs2)
adamc@748 246
adamc@750 247 class nullify :: Type -> Type -> Type
adamc@750 248 val nullify_option : t ::: Type -> nullify (option t) (option t)
adamc@750 249 val nullify_prim : t ::: Type -> sql_injectable_prim t -> nullify t (option t)
adamc@750 250
adamc@750 251 val sql_left_join : tabs1 ::: {{Type}} -> tabs2 ::: {{(Type * Type)}}
adamc@750 252 -> [tabs1 ~ tabs2]
adamc@750 253 => $(map (fn r => $(map (fn p :: (Type * Type) => nullify p.1 p.2) r)) tabs2)
adamc@750 254 -> sql_from_items tabs1 -> sql_from_items (map (map (fn p :: (Type * Type) => p.1)) tabs2)
adamc@750 255 -> sql_exp (tabs1 ++ map (map (fn p :: (Type * Type) => p.1)) tabs2) [] [] bool
adamc@750 256 -> sql_from_items (tabs1 ++ map (map (fn p :: (Type * Type) => p.2)) tabs2)
adamc@750 257
adamc@751 258 val sql_right_join : tabs1 ::: {{(Type * Type)}} -> tabs2 ::: {{Type}}
adamc@751 259 -> [tabs1 ~ tabs2]
adamc@751 260 => $(map (fn r => $(map (fn p :: (Type * Type) => nullify p.1 p.2) r)) tabs1)
adamc@751 261 -> sql_from_items (map (map (fn p :: (Type * Type) => p.1)) tabs1) -> sql_from_items tabs2
adamc@751 262 -> sql_exp (map (map (fn p :: (Type * Type) => p.1)) tabs1 ++ tabs2) [] [] bool
adamc@751 263 -> sql_from_items (map (map (fn p :: (Type * Type) => p.2)) tabs1 ++ tabs2)
adamc@751 264
adamc@751 265 val sql_full_join : tabs1 ::: {{(Type * Type)}} -> tabs2 ::: {{(Type * Type)}}
adamc@751 266 -> [tabs1 ~ tabs2]
adamc@751 267 => $(map (fn r => $(map (fn p :: (Type * Type) => nullify p.1 p.2) r)) (tabs1 ++ tabs2))
adamc@751 268 -> sql_from_items (map (map (fn p :: (Type * Type) => p.1)) tabs1)
adamc@751 269 -> sql_from_items (map (map (fn p :: (Type * Type) => p.1)) tabs2)
adamc@751 270 -> sql_exp (map (map (fn p :: (Type * Type) => p.1)) (tabs1 ++ tabs2)) [] [] bool
adamc@751 271 -> sql_from_items (map (map (fn p :: (Type * Type) => p.2)) (tabs1 ++ tabs2))
adamc@751 272
adamc@748 273 val sql_query1 : tables ::: {{Type}}
adamc@354 274 -> grouped ::: {{Type}}
adamc@354 275 -> selectedFields ::: {{Type}}
adamc@354 276 -> selectedExps ::: {Type}
adamc@748 277 -> {From : sql_from_items tables,
adamc@748 278 Where : sql_exp tables [] [] bool,
adamc@748 279 GroupBy : sql_subset tables grouped,
adamc@748 280 Having : sql_exp grouped tables [] bool,
adamc@354 281 SelectFields : sql_subset grouped selectedFields,
adamc@748 282 SelectExps : $(map (sql_exp grouped tables [])
adamc@705 283 selectedExps) }
adamc@748 284 -> sql_query1 tables selectedFields selectedExps
adamc@229 285
adamc@229 286 type sql_relop
adamc@229 287 val sql_union : sql_relop
adamc@229 288 val sql_intersect : sql_relop
adamc@229 289 val sql_except : sql_relop
adamc@260 290 val sql_relop : tables1 ::: {{Type}}
adamc@354 291 -> tables2 ::: {{Type}}
adamc@354 292 -> selectedFields ::: {{Type}}
adamc@354 293 -> selectedExps ::: {Type}
adamc@354 294 -> sql_relop
adamc@354 295 -> sql_query1 tables1 selectedFields selectedExps
adamc@354 296 -> sql_query1 tables2 selectedFields selectedExps
adamc@354 297 -> sql_query1 selectedFields selectedFields selectedExps
adamc@229 298
adamc@230 299 type sql_direction
adamc@230 300 val sql_asc : sql_direction
adamc@230 301 val sql_desc : sql_direction
adamc@230 302
adamc@234 303 con sql_order_by :: {{Type}} -> {Type} -> Type
adamc@234 304 val sql_order_by_Nil : tables ::: {{Type}} -> exps :: {Type} -> sql_order_by tables exps
adamc@234 305 val sql_order_by_Cons : tables ::: {{Type}} -> exps ::: {Type} -> t ::: Type
adamc@354 306 -> sql_exp tables [] exps t -> sql_direction
adamc@354 307 -> sql_order_by tables exps
adamc@354 308 -> sql_order_by tables exps
adamc@230 309
adamc@231 310 type sql_limit
adamc@231 311 val sql_no_limit : sql_limit
adamc@231 312 val sql_limit : int -> sql_limit
adamc@354 313
adamc@232 314 type sql_offset
adamc@232 315 val sql_no_offset : sql_offset
adamc@232 316 val sql_offset : int -> sql_offset
adamc@232 317
adamc@229 318 val sql_query : tables ::: {{Type}}
adamc@354 319 -> selectedFields ::: {{Type}}
adamc@354 320 -> selectedExps ::: {Type}
adamc@354 321 -> {Rows : sql_query1 tables selectedFields selectedExps,
adamc@354 322 OrderBy : sql_order_by tables selectedExps,
adamc@354 323 Limit : sql_limit,
adamc@354 324 Offset : sql_offset}
adamc@354 325 -> sql_query selectedFields selectedExps
adamc@204 326
adamc@354 327 val sql_field : otherTabs ::: {{Type}} -> otherFields ::: {Type}
adamc@354 328 -> fieldType ::: Type -> agg ::: {{Type}}
adamc@354 329 -> exps ::: {Type}
adamc@354 330 -> tab :: Name -> field :: Name
adamc@354 331 -> sql_exp
adamc@354 332 ([tab = [field = fieldType] ++ otherFields] ++ otherTabs)
adamc@354 333 agg exps fieldType
adamc@234 334
adamc@354 335 val sql_exp : tabs ::: {{Type}} -> agg ::: {{Type}} -> t ::: Type -> rest ::: {Type}
adamc@354 336 -> nm :: Name
adamc@354 337 -> sql_exp tabs agg ([nm = t] ++ rest) t
adamc@209 338
adamc@221 339 class sql_injectable
adamc@676 340 val sql_prim : t ::: Type -> sql_injectable_prim t -> sql_injectable t
adamc@676 341 val sql_option_prim : t ::: Type -> sql_injectable_prim t -> sql_injectable (option t)
adamc@676 342
adamc@354 343 val sql_inject : tables ::: {{Type}} -> agg ::: {{Type}} -> exps ::: {Type}
adamc@354 344 -> t ::: Type
adamc@354 345 -> sql_injectable t -> t -> sql_exp tables agg exps t
adamc@209 346
adamc@470 347 val sql_is_null : tables ::: {{Type}} -> agg ::: {{Type}} -> exps ::: {Type}
adamc@470 348 -> t ::: Type
adamc@470 349 -> sql_exp tables agg exps (option t)
adamc@470 350 -> sql_exp tables agg exps bool
adamc@470 351
adamc@559 352 class sql_arith
adamc@559 353 val sql_int_arith : sql_arith int
adamc@559 354 val sql_float_arith : sql_arith float
adamc@559 355
adamc@220 356 con sql_unary :: Type -> Type -> Type
adamc@220 357 val sql_not : sql_unary bool bool
adamc@354 358 val sql_unary : tables ::: {{Type}} -> agg ::: {{Type}} -> exps ::: {Type}
adamc@354 359 -> arg ::: Type -> res ::: Type
adamc@354 360 -> sql_unary arg res -> sql_exp tables agg exps arg
adamc@354 361 -> sql_exp tables agg exps res
adamc@220 362
adamc@559 363 val sql_neg : t ::: Type -> sql_arith t -> sql_unary t t
adamc@559 364
adamc@220 365 con sql_binary :: Type -> Type -> Type -> Type
adamc@220 366 val sql_and : sql_binary bool bool bool
adamc@220 367 val sql_or : sql_binary bool bool bool
adamc@234 368 val sql_binary : tables ::: {{Type}} -> agg ::: {{Type}} -> exps ::: {Type}
adamc@354 369 -> arg1 ::: Type -> arg2 ::: Type -> res ::: Type
adamc@354 370 -> sql_binary arg1 arg2 res -> sql_exp tables agg exps arg1
adamc@354 371 -> sql_exp tables agg exps arg2
adamc@354 372 -> sql_exp tables agg exps res
adamc@220 373
adamc@559 374 val sql_plus : t ::: Type -> sql_arith t -> sql_binary t t t
adamc@559 375 val sql_minus : t ::: Type -> sql_arith t -> sql_binary t t t
adamc@559 376 val sql_times : t ::: Type -> sql_arith t -> sql_binary t t t
adamc@559 377 val sql_div : t ::: Type -> sql_arith t -> sql_binary t t t
adamc@559 378 val sql_mod : sql_binary int int int
adamc@559 379
adamc@559 380 val sql_eq : t ::: Type -> sql_binary t t bool
adamc@559 381 val sql_ne : t ::: Type -> sql_binary t t bool
adamc@559 382 val sql_lt : t ::: Type -> sql_binary t t bool
adamc@559 383 val sql_le : t ::: Type -> sql_binary t t bool
adamc@559 384 val sql_gt : t ::: Type -> sql_binary t t bool
adamc@559 385 val sql_ge : t ::: Type -> sql_binary t t bool
adamc@203 386
adamc@235 387 val sql_count : tables ::: {{Type}} -> agg ::: {{Type}} -> exps ::: {Type}
adamc@544 388 -> sql_exp tables agg exps int
adamc@235 389
adamc@236 390 con sql_aggregate :: Type -> Type
adamc@354 391 val sql_aggregate : tables ::: {{Type}} -> agg ::: {{Type}} -> exps ::: {Type}
adamc@354 392 -> t ::: Type
adamc@354 393 -> sql_aggregate t -> sql_exp agg agg exps t
adamc@354 394 -> sql_exp tables agg exps t
adamc@236 395
adamc@236 396 class sql_summable
adamc@236 397 val sql_summable_int : sql_summable int
adamc@236 398 val sql_summable_float : sql_summable float
adamc@236 399 val sql_avg : t ::: Type -> sql_summable t -> sql_aggregate t
adamc@236 400 val sql_sum : t ::: Type -> sql_summable t -> sql_aggregate t
adamc@236 401
adamc@236 402 class sql_maxable
adamc@236 403 val sql_maxable_int : sql_maxable int
adamc@236 404 val sql_maxable_float : sql_maxable float
adamc@236 405 val sql_maxable_string : sql_maxable string
adamc@437 406 val sql_maxable_time : sql_maxable time
adamc@236 407 val sql_max : t ::: Type -> sql_maxable t -> sql_aggregate t
adamc@236 408 val sql_min : t ::: Type -> sql_maxable t -> sql_aggregate t
adamc@236 409
adamc@441 410 con sql_nfunc :: Type -> Type
adamc@441 411 val sql_nfunc : tables ::: {{Type}} -> agg ::: {{Type}} -> exps ::: {Type}
adamc@441 412 -> t ::: Type
adamc@441 413 -> sql_nfunc t -> sql_exp tables agg exps t
adamc@441 414 val sql_current_timestamp : sql_nfunc time
adamc@441 415
adamc@746 416 con sql_ufunc :: Type -> Type -> Type
adamc@746 417 val sql_ufunc : tables ::: {{Type}} -> agg ::: {{Type}} -> exps ::: {Type}
adamc@746 418 -> dom ::: Type -> ran ::: Type
adamc@746 419 -> sql_ufunc dom ran -> sql_exp tables agg exps dom
adamc@746 420 -> sql_exp tables agg exps ran
adamc@746 421 val sql_octet_length : sql_ufunc blob int
adamc@746 422
adamc@235 423
adamc@243 424 (*** Executing queries *)
adamc@243 425
adamc@354 426 val query : tables ::: {{Type}} -> exps ::: {Type}
adamc@629 427 -> [tables ~ exps] =>
adamc@354 428 state ::: Type
adamc@354 429 -> sql_query tables exps
adamc@621 430 -> ($(exps ++ map (fn fields :: {Type} => $fields) tables)
adamc@354 431 -> state
adamc@354 432 -> transaction state)
adamc@354 433 -> state
adamc@354 434 -> transaction state
adamc@243 435
adamc@243 436
adamc@299 437 (*** Database mutators *)
adamc@299 438
adamc@299 439 type dml
adamc@299 440 val dml : dml -> transaction unit
adamc@299 441
adamc@705 442 val insert : fields ::: {Type} -> uniques ::: {{Unit}}
adamc@705 443 -> sql_table fields uniques
adamc@621 444 -> $(map (fn t :: Type => sql_exp [] [] [] t) fields)
adamc@354 445 -> dml
adamc@299 446
adamc@705 447 val update : unchanged ::: {Type} -> uniques ::: {{Unit}} -> changed :: {Type} ->
adamc@629 448 [changed ~ unchanged] =>
adamc@621 449 $(map (fn t :: Type => sql_exp [T = changed ++ unchanged] [] [] t) changed)
adamc@705 450 -> sql_table (changed ++ unchanged) uniques
adamc@354 451 -> sql_exp [T = changed ++ unchanged] [] [] bool
adamc@354 452 -> dml
adamc@299 453
adamc@705 454 val delete : fields ::: {Type} -> uniques ::: {{Unit}}
adamc@705 455 -> sql_table fields uniques
adamc@354 456 -> sql_exp [T = fields] [] [] bool
adamc@354 457 -> dml
adamc@299 458
adamc@338 459 (*** Sequences *)
adamc@338 460
adamc@338 461 type sql_sequence
adamc@338 462 val nextval : sql_sequence -> transaction int
adamc@338 463
adamc@299 464
adamc@203 465 (** XML *)
adamc@203 466
adamc@721 467 type css_class
adamc@718 468
adamc@720 469 con tag :: {Type} -> {Unit} -> {Unit} -> {Type} -> {Type} -> Type
adamc@91 470
adamc@720 471 con xml :: {Unit} -> {Type} -> {Type} -> Type
adamc@720 472 val cdata : ctx ::: {Unit} -> use ::: {Type} -> string -> xml ctx use []
adamc@354 473 val tag : attrsGiven ::: {Type} -> attrsAbsent ::: {Type}
adamc@354 474 -> ctxOuter ::: {Unit} -> ctxInner ::: {Unit}
adamc@354 475 -> useOuter ::: {Type} -> useInner ::: {Type}
adamc@354 476 -> bindOuter ::: {Type} -> bindInner ::: {Type}
adamc@629 477 -> [attrsGiven ~ attrsAbsent] =>
adamc@629 478 [useOuter ~ useInner] =>
adamc@629 479 [bindOuter ~ bindInner] =>
adamc@721 480 option css_class
adamc@721 481 -> $attrsGiven
adamc@629 482 -> tag (attrsGiven ++ attrsAbsent)
adamc@720 483 ctxOuter ctxInner useOuter bindOuter
adamc@720 484 -> xml ctxInner useInner bindInner
adamc@720 485 -> xml ctxOuter (useOuter ++ useInner) (bindOuter ++ bindInner)
adamc@140 486 val join : ctx ::: {Unit}
adamc@720 487 -> use1 ::: {Type} -> bind1 ::: {Type} -> bind2 ::: {Type}
adamc@720 488 -> [use1 ~ bind1] => [bind1 ~ bind2] =>
adamc@720 489 xml ctx use1 bind1
adamc@720 490 -> xml ctx (use1 ++ bind1) bind2
adamc@720 491 -> xml ctx use1 (bind1 ++ bind2)
adamc@354 492 val useMore : ctx ::: {Unit} -> use1 ::: {Type} -> use2 ::: {Type}
adamc@720 493 -> bind ::: {Type}
adamc@629 494 -> [use1 ~ use2] =>
adamc@720 495 xml ctx use1 bind
adamc@720 496 -> xml ctx (use1 ++ use2) bind
adamc@91 497
adamc@110 498 con xhtml = xml [Html]
adamc@139 499 con page = xhtml [] []
adamc@720 500 con xbody = xml [Body] [] []
adamc@720 501 con xtr = xml [Body, Tr] [] []
adamc@720 502 con xform = xml [Body, Form] [] []
adamc@110 503
adamc@718 504
adamc@204 505 (*** HTML details *)
adamc@204 506
adamc@140 507 con html = [Html]
adamc@140 508 con head = [Head]
adamc@140 509 con body = [Body]
adamc@361 510 con form = [Body, Form]
adamc@760 511 con subform = [Body, Subform]
adamc@332 512 con tabl = [Body, Table]
adamc@332 513 con tr = [Body, Tr]
adamc@93 514
adamc@724 515 type url
adamc@724 516 val bless : string -> url
adamc@770 517 val checkUrl : string -> option url
adamc@724 518
adamc@720 519 val dyn : use ::: {Type} -> bind ::: {Type} -> unit
adamc@720 520 -> tag [Signal = signal (xml body use bind)] body [] use bind
adamc@568 521
adamc@720 522 val head : unit -> tag [] html head [] []
adamc@720 523 val title : unit -> tag [] head [] [] []
adamc@724 524 val link : unit -> tag [Rel = string, Typ = string, Href = url, Media = string] head [] [] []
adamc@110 525
adamc@720 526 val body : unit -> tag [Onload = transaction unit] html body [] []
adamc@354 527 con bodyTag = fn (attrs :: {Type}) =>
adamc@354 528 ctx ::: {Unit} ->
adamc@629 529 [[Body] ~ ctx] =>
adamc@720 530 unit -> tag attrs ([Body] ++ ctx) ([Body] ++ ctx) [] []
adamc@354 531 con bodyTagStandalone = fn (attrs :: {Type}) =>
adamc@354 532 ctx ::: {Unit}
adamc@629 533 -> [[Body] ~ ctx] =>
adamc@720 534 unit -> tag attrs ([Body] ++ ctx) [] [] []
adamc@141 535
adamc@141 536 val br : bodyTagStandalone []
adamc@119 537
adamc@691 538 val span : bodyTag []
adamc@775 539 val div : bodyTag []
adamc@691 540
adamc@140 541 val p : bodyTag []
adamc@140 542 val b : bodyTag []
adamc@140 543 val i : bodyTag []
adamc@407 544 val tt : bodyTag []
adamc@140 545 val font : bodyTag [Size = int, Face = string]
adamc@140 546
adamc@140 547 val h1 : bodyTag []
adamc@443 548 val h2 : bodyTag []
adamc@443 549 val h3 : bodyTag []
adamc@443 550 val h4 : bodyTag []
adamc@469 551
adamc@140 552 val li : bodyTag []
adamc@469 553 val ol : bodyTag []
adamc@469 554 val ul : bodyTag []
adamc@140 555
adamc@410 556 val hr : bodyTag []
adamc@410 557
adamc@720 558 val a : bodyTag [Link = transaction page, Href = url, Onclick = transaction unit]
adamc@717 559
adamc@717 560 val img : bodyTag [Src = url]
adamc@140 561
adamc@720 562 val form : ctx ::: {Unit} -> bind ::: {Type}
adamc@756 563 -> [[Body] ~ ctx] =>
adamc@756 564 xml form [] bind
adamc@756 565 -> xml ([Body] ++ ctx) [] []
adamc@756 566
adamc@756 567 val subform : ctx ::: {Unit} -> use ::: {Type} -> bind ::: {Type}
adamc@756 568 -> [[Form] ~ ctx] =>
adamc@756 569 nm :: Name -> [[nm] ~ use] =>
adamc@756 570 xml form [] bind
adamc@756 571 -> xml ([Form] ++ ctx) use [nm = $bind]
adamc@758 572
adamc@758 573 val subforms : ctx ::: {Unit} -> use ::: {Type} -> bind ::: {Type}
adamc@758 574 -> [[Form] ~ ctx] =>
adamc@758 575 nm :: Name -> [[nm] ~ use] =>
adamc@760 576 xml subform [Entry = $bind] []
adamc@758 577 -> xml ([Form] ++ ctx) use [nm = list ($bind)]
adamc@758 578
adamc@758 579 val entry : ctx ::: {Unit} -> bind ::: {Type}
adamc@758 580 -> [[Subform] ~ ctx] =>
adamc@758 581 xml form [] bind
adamc@758 582 -> xml ([Subform] ++ ctx) [Entry = $bind] []
adamc@758 583
adamc@361 584 con formTag = fn (ty :: Type) (inner :: {Unit}) (attrs :: {Type}) =>
adamc@354 585 ctx ::: {Unit}
adamc@629 586 -> [[Form] ~ ctx] =>
adamc@354 587 nm :: Name -> unit
adamc@720 588 -> tag attrs ([Form] ++ ctx) inner [] [nm = ty]
adamc@761 589 val hidden : formTag string [] [Value = string]
adamc@598 590 val textbox : formTag string [] [Value = string, Size = int, Source = source string]
adamc@444 591 val password : formTag string [] [Value = string, Size = int]
adamc@444 592 val textarea : formTag string [] [Rows = int, Cols = int]
adamc@153 593
adamc@361 594 val checkbox : formTag bool [] [Checked = bool]
adamc@190 595
adamc@737 596 type file
adamc@737 597 val fileName : file -> option string
adamc@740 598 val fileMimeType : file -> string
adamc@737 599 val fileData : file -> blob
adamc@737 600
adamc@739 601 val upload : formTag file [] [Value = string, Size = int]
adamc@737 602
adamc@741 603 type mimeType
adamc@741 604 val blessMime : string -> mimeType
adamc@770 605 val checkMime : string -> option mimeType
adamc@741 606 val returnBlob : t ::: Type -> blob -> mimeType -> transaction t
adamc@745 607 val blobSize : blob -> int
adamc@741 608
adamc@153 609 con radio = [Body, Radio]
adamc@361 610 val radio : formTag string radio []
adamc@720 611 val radioOption : unit -> tag [Value = string] radio [] [] []
adamc@142 612
adamc@154 613 con select = [Select]
adamc@361 614 val select : formTag string select []
adamc@720 615 val option : unit -> tag [Value = string, Selected = bool] select [] [] []
adamc@154 616
adamc@720 617 val submit : ctx ::: {Unit} -> use ::: {Type}
adamc@629 618 -> [[Form] ~ ctx] =>
adamc@354 619 unit
adamc@720 620 -> tag [Value = string, Action = $use -> transaction page]
adamc@720 621 ([Form] ++ ctx) ([Form] ++ ctx) use []
adamc@283 622
adamc@601 623 (*** AJAX-oriented widgets *)
adamc@601 624
adamc@601 625 con cformTag = fn (attrs :: {Type}) =>
adamc@601 626 ctx ::: {Unit}
adamc@629 627 -> [[Body] ~ ctx] =>
adamc@720 628 unit -> tag attrs ([Body] ++ ctx) [] [] []
adamc@601 629
adamc@601 630 val ctextbox : cformTag [Value = string, Size = int, Source = source string]
adamc@601 631 val button : cformTag [Value = string, Onclick = transaction unit]
adamc@601 632
adamc@720 633 (*** Tables *)
adamc@720 634
adamc@720 635 val tabl : other ::: {Unit} -> [other ~ [Body, Table]] =>
adamc@720 636 unit -> tag [Border = int] ([Body] ++ other) ([Body, Table] ++ other) [] []
adamc@720 637 val tr : other ::: {Unit} -> [other ~ [Body, Table, Tr]] =>
adamc@720 638 unit -> tag [] ([Body, Table] ++ other) ([Body, Tr] ++ other) [] []
adamc@720 639 val th : other ::: {Unit} -> [other ~ [Body, Tr]] =>
adamc@720 640 unit -> tag [] ([Body, Tr] ++ other) ([Body] ++ other) [] []
adamc@720 641 val td : other ::: {Unit} -> [other ~ [Body, Tr]] =>
adamc@720 642 unit -> tag [] ([Body, Tr] ++ other) ([Body] ++ other) [] []
adamc@720 643
adamc@283 644
adamc@283 645 (** Aborting *)
adamc@283 646
adamc@726 647 val error : t ::: Type -> xbody -> t
adamc@720 648
adamc@729 649 (* Client-side-only handlers: *)
adamc@726 650 val onError : (xbody -> transaction unit) -> transaction unit
adamc@728 651 val onFail : (string -> transaction unit) -> transaction unit
adamc@729 652 val onConnectFail : transaction unit -> transaction unit
adamc@729 653 val onDisconnect : transaction unit -> transaction unit
adamc@729 654 val onServerError : (string -> transaction unit) -> transaction unit
adamc@727 655
adamc@727 656 val show_xml : ctx ::: {Unit} -> use ::: {Type} -> bind ::: {Type} -> show (xml ctx use bind)