annotate lib/basis.lig @ 209:1487c712eb12

Stub WHERE support
author Adam Chlipala <adamc@hcoop.net>
date Sat, 16 Aug 2008 12:15:38 -0400
parents cc68da3801bc
children 38b299373676
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@209 17 con sql_exp :: {{Type}} -> Type -> Type
adamc@204 18
adamc@207 19 val sql_query : tables :: {({Type} * {Type})}
adamc@209 20 -> {From : $(fold (fn nm => fn selected_unselected :: ({Type} * {Type}) => fn acc =>
adamc@207 21 [nm] ~ acc => selected_unselected.1 ~ selected_unselected.2 =>
adamc@209 22 [nm = sql_table (selected_unselected.1 ++ selected_unselected.2)] ++ acc) [] tables),
adamc@209 23 Where : sql_exp (fold (fn nm => fn selected_unselected :: ({Type} * {Type}) => fn acc =>
adamc@209 24 [nm] ~ acc => selected_unselected.1 ~ selected_unselected.2 =>
adamc@209 25 [nm = selected_unselected.1 ++ selected_unselected.2] ++ acc) [] tables) bool}
adamc@207 26 -> sql_query (fold (fn nm => fn selected_unselected :: ({Type} * {Type}) => fn acc => [nm] ~ acc =>
adamc@207 27 [nm = selected_unselected.1] ++ acc) [] tables)
adamc@204 28
adamc@209 29 con sql_type :: Type -> Type
adamc@209 30 val sql_bool : sql_type bool
adamc@209 31 val sql_int : sql_type int
adamc@209 32 val sql_float : sql_type float
adamc@209 33 val sql_string : sql_type string
adamc@209 34
adamc@209 35 val sql_inject : tables ::: {{Type}} -> t ::: Type -> t -> sql_type t -> sql_exp tables t
adamc@209 36
adamc@203 37
adamc@203 38 (** XML *)
adamc@203 39
adamc@139 40 con tag :: {Type} -> {Unit} -> {Unit} -> {Type} -> {Type} -> Type
adamc@91 41
adamc@91 42
adamc@139 43 con xml :: {Unit} -> {Type} -> {Type} -> Type
adamc@141 44 val cdata : ctx ::: {Unit} -> use ::: {Type} -> string -> xml ctx use []
adamc@104 45 val tag : attrsGiven ::: {Type} -> attrsAbsent ::: {Type} -> attrsGiven ~ attrsAbsent
adamc@139 46 -> ctxOuter ::: {Unit} -> ctxInner ::: {Unit}
adamc@139 47 -> useOuter ::: {Type} -> useInner ::: {Type} -> useOuter ~ useInner
adamc@139 48 -> bindOuter ::: {Type} -> bindInner ::: {Type} -> bindOuter ~ bindInner
adamc@104 49 -> $attrsGiven
adamc@139 50 -> tag (attrsGiven ++ attrsAbsent) ctxOuter ctxInner useOuter bindOuter
adamc@139 51 -> xml ctxInner useInner bindInner
adamc@139 52 -> xml ctxOuter (useOuter ++ useInner) (bindOuter ++ bindInner)
adamc@140 53 val join : ctx ::: {Unit}
adamc@139 54 -> use1 ::: {Type} -> bind1 ::: {Type} -> bind2 ::: {Type}
adamc@139 55 -> use1 ~ bind1 -> bind1 ~ bind2
adamc@140 56 -> xml ctx use1 bind1
adamc@140 57 -> xml ctx (use1 ++ bind1) bind2
adamc@140 58 -> xml ctx use1 (bind1 ++ bind2)
adamc@148 59 val useMore : ctx ::: {Unit} -> use1 ::: {Type} -> use2 ::: {Type} -> bind ::: {Type}
adamc@148 60 -> use1 ~ use2
adamc@148 61 -> xml ctx use1 bind
adamc@148 62 -> xml ctx (use1 ++ use2) bind
adamc@91 63
adamc@110 64 con xhtml = xml [Html]
adamc@139 65 con page = xhtml [] []
adamc@110 66
adamc@204 67 (*** HTML details *)
adamc@204 68
adamc@140 69 con html = [Html]
adamc@140 70 con head = [Head]
adamc@140 71 con body = [Body]
adamc@141 72 con lform = [Body, LForm]
adamc@93 73
adamc@140 74 val head : unit -> tag [] html head [] []
adamc@140 75 val title : unit -> tag [] head [] [] []
adamc@110 76
adamc@140 77 val body : unit -> tag [] html body [] []
adamc@140 78 con bodyTag = fn attrs :: {Type} => ctx ::: {Unit} -> [Body] ~ ctx -> unit
adamc@140 79 -> tag attrs ([Body] ++ ctx) ([Body] ++ ctx) [] []
adamc@141 80 con bodyTagStandalone = fn attrs :: {Type} => ctx ::: {Unit} -> [Body] ~ ctx -> unit
adamc@141 81 -> tag attrs ([Body] ++ ctx) [] [] []
adamc@141 82
adamc@141 83 val br : bodyTagStandalone []
adamc@119 84
adamc@140 85 val p : bodyTag []
adamc@140 86 val b : bodyTag []
adamc@140 87 val i : bodyTag []
adamc@140 88 val font : bodyTag [Size = int, Face = string]
adamc@140 89
adamc@140 90 val h1 : bodyTag []
adamc@140 91 val li : bodyTag []
adamc@140 92
adamc@140 93 val a : bodyTag [Link = page]
adamc@140 94
adamc@141 95 val lform : ctx ::: {Unit} -> [Body] ~ ctx -> bind ::: {Type}
adamc@141 96 -> xml lform [] bind
adamc@141 97 -> xml ([Body] ++ ctx) [] []
adamc@153 98 con lformTag = fn ty :: Type => fn inner :: {Unit} => fn attrs :: {Type} =>
adamc@141 99 ctx ::: {Unit} -> [LForm] ~ ctx
adamc@141 100 -> nm :: Name -> unit
adamc@153 101 -> tag attrs ([LForm] ++ ctx) inner [] [nm = ty]
adamc@153 102 val textbox : lformTag string [] []
adamc@155 103 val password : lformTag string [] []
adamc@153 104 val ltextarea : lformTag string [] []
adamc@153 105
adamc@190 106 val checkbox : lformTag bool [] []
adamc@190 107
adamc@153 108 con radio = [Body, Radio]
adamc@153 109 val radio : lformTag string radio []
adamc@153 110 val radioOption : unit -> tag [Value = string] radio [] [] []
adamc@142 111
adamc@154 112 con select = [Select]
adamc@154 113 val lselect : lformTag string select []
adamc@154 114 val loption : unit -> tag [Value = string] select [] [] []
adamc@154 115
adamc@142 116 val submit : ctx ::: {Unit} -> [LForm] ~ ctx
adamc@142 117 -> use ::: {Type} -> unit
adamc@142 118 -> tag [Action = $use -> page] ([LForm] ++ ctx) ([LForm] ++ ctx) use []