annotate lib/ur/top.urs @ 1064:b89e3d8731ed

Make oneRowE1 more general
author Adam Chlipala <adamc@hcoop.net>
date Thu, 10 Dec 2009 12:06:03 -0500
parents 5d9f47124c4c
children 9001966ae1c8
rev   line source
adamc@623 1 (** Row folding *)
adamc@623 2
adamc@631 3 con folder :: K --> {K} -> Type
adamc@623 4
adamc@653 5 val fold : K --> tf :: ({K} -> Type)
adamc@653 6 -> (nm :: Name -> v :: K -> r :: {K} -> [[nm] ~ r] =>
adamc@653 7 tf r -> tf ([nm = v] ++ r))
adamc@653 8 -> tf []
adamc@653 9 -> r :: {K} -> folder r -> tf r
adamc@653 10
adamc@627 11 structure Folder : sig
adamc@627 12 val nil : K --> folder (([]) :: {K})
adamc@627 13 val cons : K --> r ::: {K} -> nm :: Name -> v :: K
adamc@629 14 -> [[nm] ~ r] => folder r -> folder ([nm = v] ++ r)
adamc@628 15 val concat : K --> r1 ::: {K} -> r2 ::: {K}
adamc@629 16 -> [r1 ~ r2] => folder r1 -> folder r2 -> folder (r1 ++ r2)
adamc@630 17 val mp : K1 --> K2 --> f ::: (K1 -> K2) -> r ::: {K1}
adamc@630 18 -> folder r -> folder (map f r)
adamc@627 19 end
adamc@627 20
adamc@623 21
adamc@422 22 val not : bool -> bool
adamc@422 23
adamc@898 24 con id = K ==> fn t :: K => t
adamc@329 25 con record = fn t :: {Type} => $t
adamc@637 26 con fst = K1 ==> K2 ==> fn t :: (K1 * K2) => t.1
adamc@637 27 con snd = K1 ==> K2 ==> fn t :: (K1 * K2) => t.2
adamc@637 28 con fst3 = K1 ==> K2 ==> K3 ==> fn t :: (K1 * K2 * K3) => t.1
adamc@637 29 con snd3 = K1 ==> K2 ==> K3 ==> fn t :: (K1 * K2 * K3) => t.2
adamc@637 30 con thd3 = K1 ==> K2 ==> K3 ==> fn t :: (K1 * K2 * K3) => t.3
adamc@329 31
adamc@643 32 con mapU = K ==> fn f :: K => map (fn _ :: Unit => f)
adamc@445 33
adamc@339 34 con ex = fn tf :: (Type -> Type) =>
adamc@355 35 res ::: Type -> (choice :: Type -> tf choice -> res) -> res
adamc@339 36
adamc@339 37 val ex : tf :: (Type -> Type) -> choice :: Type -> tf choice -> ex tf
adamc@339 38
adamc@325 39 val compose : t1 ::: Type -> t2 ::: Type -> t3 ::: Type
adamc@355 40 -> (t2 -> t3) -> (t1 -> t2) -> (t1 -> t3)
adamc@325 41
adamc@777 42 val show_option : t ::: Type -> show t -> show (option t)
adamc@777 43 val read_option : t ::: Type -> read t -> read (option t)
adamc@777 44
adamc@720 45 val txt : t ::: Type -> ctx ::: {Unit} -> use ::: {Type} -> show t -> t
adamc@720 46 -> xml ctx use []
adamc@329 47
adamc@993 48 val map0 : K --> tf :: (K -> Type)
adamc@993 49 -> (t :: K -> tf t)
adamc@993 50 -> r :: {K} -> folder r -> $(map tf r)
adamc@898 51 val mp : K --> tf1 :: (K -> Type) -> tf2 :: (K -> Type)
adamc@898 52 -> (t ::: K -> tf1 t -> tf2 t)
adamc@898 53 -> r :: {K} -> folder r -> $(map tf1 r) -> $(map tf2 r)
adamc@937 54 val map2 : K --> tf1 :: (K -> Type) -> tf2 :: (K -> Type) -> tf :: (K -> Type)
adamc@937 55 -> (t ::: K -> tf1 t -> tf2 t -> tf t)
adamc@937 56 -> r :: {K} -> folder r -> $(map tf1 r) -> $(map tf2 r) -> $(map tf r)
adamc@937 57 val map3 : K --> tf1 :: (K -> Type) -> tf2 :: (K -> Type) -> tf3 :: (K -> Type) -> tf :: (K -> Type)
adamc@937 58 -> (t ::: K -> tf1 t -> tf2 t -> tf3 t -> tf t)
adamc@937 59 -> r :: {K} -> folder r -> $(map tf1 r) -> $(map tf2 r) -> $(map tf3 r) -> $(map tf r)
adamc@898 60
adamc@411 61 val foldUR : tf :: Type -> tr :: ({Unit} -> Type)
adamc@411 62 -> (nm :: Name -> rest :: {Unit}
adamc@629 63 -> [[nm] ~ rest] =>
adamc@411 64 tf -> tr rest -> tr ([nm] ++ rest))
adamc@643 65 -> tr [] -> r :: {Unit} -> folder r -> $(mapU tf r) -> tr r
adamc@411 66
adamc@418 67 val foldUR2 : tf1 :: Type -> tf2 :: Type -> tr :: ({Unit} -> Type)
adamc@418 68 -> (nm :: Name -> rest :: {Unit}
adamc@629 69 -> [[nm] ~ rest] =>
adamc@418 70 tf1 -> tf2 -> tr rest -> tr ([nm] ++ rest))
adamc@643 71 -> tr [] -> r :: {Unit} -> folder r -> $(mapU tf1 r) -> $(mapU tf2 r) -> tr r
adamc@418 72
adamc@720 73 val foldURX2: tf1 :: Type -> tf2 :: Type -> ctx :: {Unit}
adamc@418 74 -> (nm :: Name -> rest :: {Unit}
adamc@629 75 -> [[nm] ~ rest] =>
adamc@720 76 tf1 -> tf2 -> xml ctx [] [])
adamc@720 77 -> r :: {Unit} -> folder r -> $(mapU tf1 r) -> $(mapU tf2 r) -> xml ctx [] []
adamc@418 78
adamc@623 79 val foldR : K --> tf :: (K -> Type) -> tr :: ({K} -> Type)
adamc@623 80 -> (nm :: Name -> t :: K -> rest :: {K}
adamc@629 81 -> [[nm] ~ rest] =>
adamc@355 82 tf t -> tr rest -> tr ([nm = t] ++ rest))
adamc@632 83 -> tr [] -> r :: {K} -> folder r -> $(map tf r) -> tr r
adamc@336 84
adamc@623 85 val foldR2 : K --> tf1 :: (K -> Type) -> tf2 :: (K -> Type)
adamc@623 86 -> tr :: ({K} -> Type)
adamc@623 87 -> (nm :: Name -> t :: K -> rest :: {K}
adamc@629 88 -> [[nm] ~ rest] =>
adamc@623 89 tf1 t -> tf2 t -> tr rest -> tr ([nm = t] ++ rest))
adamc@623 90 -> tr []
adamc@632 91 -> r :: {K} -> folder r -> $(map tf1 r) -> $(map tf2 r) -> tr r
adamc@623 92
adamc@910 93 val foldR3 : K --> tf1 :: (K -> Type) -> tf2 :: (K -> Type) -> tf3 :: (K -> Type)
adamc@910 94 -> tr :: ({K} -> Type)
adamc@910 95 -> (nm :: Name -> t :: K -> rest :: {K}
adamc@910 96 -> [[nm] ~ rest] =>
adamc@910 97 tf1 t -> tf2 t -> tf3 t -> tr rest -> tr ([nm = t] ++ rest))
adamc@910 98 -> tr []
adamc@910 99 -> r :: {K} -> folder r -> $(map tf1 r) -> $(map tf2 r) -> $(map tf3 r) -> tr r
adamc@910 100
adamc@720 101 val foldRX : K --> tf :: (K -> Type) -> ctx :: {Unit}
adamc@623 102 -> (nm :: Name -> t :: K -> rest :: {K}
adamc@629 103 -> [[nm] ~ rest] =>
adamc@720 104 tf t -> xml ctx [] [])
adamc@720 105 -> r :: {K} -> folder r -> $(map tf r) -> xml ctx [] []
adamc@623 106
adamc@720 107 val foldRX2 : K --> tf1 :: (K -> Type) -> tf2 :: (K -> Type) -> ctx :: {Unit}
adamc@623 108 -> (nm :: Name -> t :: K -> rest :: {K}
adamc@629 109 -> [[nm] ~ rest] =>
adamc@720 110 tf1 t -> tf2 t -> xml ctx [] [])
adamc@632 111 -> r :: {K} -> folder r
adamc@720 112 -> $(map tf1 r) -> $(map tf2 r) -> xml ctx [] []
adamc@445 113
adamc@910 114 val foldRX3 : K --> tf1 :: (K -> Type) -> tf2 :: (K -> Type) -> tf3 :: (K -> Type) -> ctx :: {Unit}
adamc@910 115 -> (nm :: Name -> t :: K -> rest :: {K}
adamc@910 116 -> [[nm] ~ rest] =>
adamc@910 117 tf1 t -> tf2 t -> tf3 t -> xml ctx [] [])
adamc@910 118 -> r :: {K} -> folder r
adamc@910 119 -> $(map tf1 r) -> $(map tf2 r) -> $(map tf3 r) -> xml ctx [] []
adamc@910 120
adamc@682 121 val queryI : tables ::: {{Type}} -> exps ::: {Type}
adamc@682 122 -> [tables ~ exps] =>
adamc@682 123 sql_query tables exps
adamc@682 124 -> ($(exps ++ map (fn fields :: {Type} => $fields) tables)
adamc@682 125 -> transaction unit)
adamc@682 126 -> transaction unit
adamc@682 127
adamc@1004 128 val queryX : tables ::: {{Type}} -> exps ::: {Type} -> ctx ::: {Unit} -> inp ::: {Type}
adamc@629 129 -> [tables ~ exps] =>
adamc@632 130 sql_query tables exps
adamc@632 131 -> ($(exps ++ map (fn fields :: {Type} => $fields) tables)
adamc@1004 132 -> xml ctx inp [])
adamc@1004 133 -> transaction (xml ctx inp [])
adamc@341 134
adamc@1032 135 val queryX' : tables ::: {{Type}} -> exps ::: {Type} -> ctx ::: {Unit} -> inp ::: {Type}
adamc@629 136 -> [tables ~ exps] =>
adamc@632 137 sql_query tables exps
adamc@632 138 -> ($(exps ++ map (fn fields :: {Type} => $fields) tables)
adamc@1032 139 -> transaction (xml ctx inp []))
adamc@1032 140 -> transaction (xml ctx inp [])
adamc@469 141
adamc@355 142 val oneOrNoRows : tables ::: {{Type}} -> exps ::: {Type}
adamc@629 143 -> [tables ~ exps] =>
adamc@629 144 sql_query tables exps
adamc@629 145 -> transaction
adamc@629 146 (option
adamc@629 147 $(exps
adamc@629 148 ++ map (fn fields :: {Type} => $fields) tables))
adamc@440 149
adamc@1003 150 val oneOrNoRows1 : nm ::: Name -> fs ::: {Type}
adamc@1003 151 -> sql_query [nm = fs] []
adamc@1003 152 -> transaction (option $fs)
adamc@1003 153
adamc@1006 154 val oneOrNoRowsE1 : tab ::: Name -> nm ::: Name -> t ::: Type
adamc@1006 155 -> [[tab] ~ [nm]] =>
adamc@1006 156 sql_query [tab = []] [nm = t]
adamc@1006 157 -> transaction (option t)
adamc@1006 158
adamc@440 159 val oneRow : tables ::: {{Type}} -> exps ::: {Type}
adamc@629 160 -> [tables ~ exps] =>
adamc@629 161 sql_query tables exps
adamc@629 162 -> transaction
adamc@629 163 $(exps
adamc@629 164 ++ map (fn fields :: {Type} => $fields) tables)
adamc@1003 165
adamc@1064 166 val oneRowE1 : tabs ::: {Unit} -> nm ::: Name -> t ::: Type
adamc@1064 167 -> [tabs ~ [nm]] =>
adamc@1064 168 sql_query (mapU [] tabs) [nm = t]
adamc@1003 169 -> transaction t
adamc@1003 170
adamc@470 171 val eqNullable : tables ::: {{Type}} -> agg ::: {{Type}} -> exps ::: {Type}
adamc@470 172 -> t ::: Type -> sql_injectable (option t)
adamc@470 173 -> sql_exp tables agg exps (option t)
adamc@470 174 -> sql_exp tables agg exps (option t)
adamc@470 175 -> sql_exp tables agg exps bool
adamc@470 176
adamc@470 177 val eqNullable' : tables ::: {{Type}} -> agg ::: {{Type}} -> exps ::: {Type}
adamc@470 178 -> t ::: Type -> sql_injectable (option t)
adamc@470 179 -> sql_exp tables agg exps (option t)
adamc@470 180 -> option t
adamc@470 181 -> sql_exp tables agg exps bool