annotate lib/ur/top.urs @ 627:f4f2b09a533a

demo/sum working with manual folders
author Adam Chlipala <adamc@hcoop.net>
date Sun, 22 Feb 2009 17:39:55 -0500
parents 588b9d16b00a
children 12b73f3c108e
rev   line source
adamc@623 1 (** Row folding *)
adamc@623 2
adamc@623 3 con folder = K ==> fn r :: {K} =>
adamc@623 4 tf :: ({K} -> Type)
adamc@623 5 -> (nm :: Name -> v :: K -> r :: {K} -> tf r
adamc@623 6 -> fn [[nm] ~ r] => tf ([nm = v] ++ r))
adamc@623 7 -> tf [] -> tf r
adamc@623 8
adamc@627 9 structure Folder : sig
adamc@627 10 val nil : K --> folder (([]) :: {K})
adamc@627 11 val cons : K --> r ::: {K} -> nm :: Name -> v :: K
adamc@627 12 -> fn [[nm] ~ r] => folder r -> folder ([nm = v] ++ r)
adamc@627 13 end
adamc@627 14
adamc@623 15
adamc@422 16 val not : bool -> bool
adamc@422 17
adamc@329 18 con idT = fn t :: Type => t
adamc@329 19 con record = fn t :: {Type} => $t
adamc@339 20 con fstTT = fn t :: (Type * Type) => t.1
adamc@339 21 con sndTT = fn t :: (Type * Type) => t.2
adamc@445 22 con fstTTT = fn t :: (Type * Type * Type) => t.1
adamc@445 23 con sndTTT = fn t :: (Type * Type * Type) => t.2
adamc@445 24 con thdTTT = fn t :: (Type * Type * Type) => t.3
adamc@329 25
adamc@621 26 con mapUT = fn f :: Type => map (fn _ :: Unit => f)
adamc@445 27
adamc@339 28 con ex = fn tf :: (Type -> Type) =>
adamc@355 29 res ::: Type -> (choice :: Type -> tf choice -> res) -> res
adamc@339 30
adamc@339 31 val ex : tf :: (Type -> Type) -> choice :: Type -> tf choice -> ex tf
adamc@339 32
adamc@325 33 val compose : t1 ::: Type -> t2 ::: Type -> t3 ::: Type
adamc@355 34 -> (t2 -> t3) -> (t1 -> t2) -> (t1 -> t3)
adamc@325 35
adamc@325 36 val txt : t ::: Type -> ctx ::: {Unit} -> use ::: {Type} -> show t -> t
adamc@355 37 -> xml ctx use []
adamc@329 38
adamc@411 39 val foldUR : tf :: Type -> tr :: ({Unit} -> Type)
adamc@411 40 -> (nm :: Name -> rest :: {Unit}
adamc@411 41 -> fn [[nm] ~ rest] =>
adamc@411 42 tf -> tr rest -> tr ([nm] ++ rest))
adamc@623 43 -> tr [] -> r ::: {Unit} -> folder r -> $(mapUT tf r) -> tr r
adamc@411 44
adamc@418 45 val foldUR2 : tf1 :: Type -> tf2 :: Type -> tr :: ({Unit} -> Type)
adamc@418 46 -> (nm :: Name -> rest :: {Unit}
adamc@418 47 -> fn [[nm] ~ rest] =>
adamc@418 48 tf1 -> tf2 -> tr rest -> tr ([nm] ++ rest))
adamc@623 49 -> tr [] -> r ::: {Unit} -> folder r -> $(mapUT tf1 r) -> $(mapUT tf2 r) -> tr r
adamc@418 50
adamc@418 51 val foldURX2: tf1 :: Type -> tf2 :: Type -> ctx :: {Unit}
adamc@418 52 -> (nm :: Name -> rest :: {Unit}
adamc@418 53 -> fn [[nm] ~ rest] =>
adamc@418 54 tf1 -> tf2 -> xml ctx [] [])
adamc@623 55 -> r ::: {Unit} -> folder r -> $(mapUT tf1 r) -> $(mapUT tf2 r) -> xml ctx [] []
adamc@418 56
adamc@623 57 val foldR : K --> tf :: (K -> Type) -> tr :: ({K} -> Type)
adamc@623 58 -> (nm :: Name -> t :: K -> rest :: {K}
adamc@355 59 -> fn [[nm] ~ rest] =>
adamc@355 60 tf t -> tr rest -> tr ([nm = t] ++ rest))
adamc@623 61 -> tr [] -> r ::: {K} -> folder r -> $(map tf r) -> tr r
adamc@336 62
adamc@623 63 val foldR2 : K --> tf1 :: (K -> Type) -> tf2 :: (K -> Type)
adamc@623 64 -> tr :: ({K} -> Type)
adamc@623 65 -> (nm :: Name -> t :: K -> rest :: {K}
adamc@623 66 -> fn [[nm] ~ rest] =>
adamc@623 67 tf1 t -> tf2 t -> tr rest -> tr ([nm = t] ++ rest))
adamc@623 68 -> tr []
adamc@623 69 -> r ::: {K} -> folder r -> $(map tf1 r) -> $(map tf2 r) -> tr r
adamc@623 70
adamc@623 71 val foldRX : K --> tf :: (K -> Type) -> ctx :: {Unit}
adamc@623 72 -> (nm :: Name -> t :: K -> rest :: {K}
adamc@623 73 -> fn [[nm] ~ rest] =>
adamc@623 74 tf t -> xml ctx [] [])
adamc@623 75 -> r ::: {K} -> folder r -> $(map tf r) -> xml ctx [] []
adamc@623 76
adamc@623 77 val foldRX2 : K --> tf1 :: (K -> Type) -> tf2 :: (K -> Type) -> ctx :: {Unit}
adamc@623 78 -> (nm :: Name -> t :: K -> rest :: {K}
adamc@355 79 -> fn [[nm] ~ rest] =>
adamc@623 80 tf1 t -> tf2 t -> xml ctx [] [])
adamc@623 81 -> r ::: {K} -> folder r
adamc@623 82 -> $(map tf1 r) -> $(map tf2 r) -> xml ctx [] []
adamc@445 83
adamc@334 84 val queryX : tables ::: {{Type}} -> exps ::: {Type} -> ctx ::: {Unit}
adamc@355 85 -> sql_query tables exps
adamc@355 86 -> fn [tables ~ exps] =>
adamc@621 87 ($(exps ++ map (fn fields :: {Type} => $fields) tables)
adamc@355 88 -> xml ctx [] [])
adamc@355 89 -> transaction (xml ctx [] [])
adamc@341 90
adamc@469 91 val queryX' : tables ::: {{Type}} -> exps ::: {Type} -> ctx ::: {Unit}
adamc@469 92 -> sql_query tables exps
adamc@469 93 -> fn [tables ~ exps] =>
adamc@621 94 ($(exps ++ map (fn fields :: {Type} => $fields) tables)
adamc@469 95 -> transaction (xml ctx [] []))
adamc@469 96 -> transaction (xml ctx [] [])
adamc@469 97
adamc@355 98 val oneOrNoRows : tables ::: {{Type}} -> exps ::: {Type}
adamc@355 99 -> sql_query tables exps
adamc@355 100 -> fn [tables ~ exps] =>
adamc@355 101 transaction
adamc@355 102 (option
adamc@355 103 $(exps
adamc@621 104 ++ map (fn fields :: {Type} => $fields) tables))
adamc@440 105
adamc@440 106 val oneRow : tables ::: {{Type}} -> exps ::: {Type}
adamc@440 107 -> sql_query tables exps
adamc@440 108 -> fn [tables ~ exps] =>
adamc@440 109 transaction
adamc@440 110 $(exps
adamc@621 111 ++ map (fn fields :: {Type} => $fields) tables)
adamc@470 112
adamc@470 113 val eqNullable : tables ::: {{Type}} -> agg ::: {{Type}} -> exps ::: {Type}
adamc@470 114 -> t ::: Type -> sql_injectable (option t)
adamc@470 115 -> sql_exp tables agg exps (option t)
adamc@470 116 -> sql_exp tables agg exps (option t)
adamc@470 117 -> sql_exp tables agg exps bool
adamc@470 118
adamc@470 119 val eqNullable' : tables ::: {{Type}} -> agg ::: {{Type}} -> exps ::: {Type}
adamc@470 120 -> t ::: Type -> sql_injectable (option t)
adamc@470 121 -> sql_exp tables agg exps (option t)
adamc@470 122 -> option t
adamc@470 123 -> sql_exp tables agg exps bool