annotate lib/basis.lig @ 204:241c9a0e3397

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