annotate lib/ur/top.urs @ 648:3c6d535d3d8b

Increment demo
author Adam Chlipala <adamc@hcoop.net>
date Tue, 10 Mar 2009 13:57:09 -0400
parents aa2290c32ce2
children fcf0bd3d1667
rev   line source
adamc@623 1 (** Row folding *)
adamc@623 2
adamc@631 3 con folder :: K --> {K} -> Type
adamc@623 4
adamc@627 5 structure Folder : sig
adamc@631 6 val fold : K --> r ::: {K} -> folder r
adamc@631 7 -> tf :: ({K} -> Type)
adamc@631 8 -> (nm :: Name -> v :: K -> r :: {K} -> tf r
adamc@631 9 -> [[nm] ~ r] => tf ([nm = v] ++ r))
adamc@631 10 -> tf [] -> tf r
adamc@631 11
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@329 24 con idT = fn t :: Type => 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@325 42 val txt : t ::: Type -> ctx ::: {Unit} -> use ::: {Type} -> show t -> t
adamc@355 43 -> xml ctx use []
adamc@329 44
adamc@411 45 val foldUR : tf :: Type -> tr :: ({Unit} -> Type)
adamc@411 46 -> (nm :: Name -> rest :: {Unit}
adamc@629 47 -> [[nm] ~ rest] =>
adamc@411 48 tf -> tr rest -> tr ([nm] ++ rest))
adamc@643 49 -> tr [] -> r :: {Unit} -> folder r -> $(mapU tf r) -> tr r
adamc@411 50
adamc@418 51 val foldUR2 : tf1 :: Type -> tf2 :: Type -> tr :: ({Unit} -> Type)
adamc@418 52 -> (nm :: Name -> rest :: {Unit}
adamc@629 53 -> [[nm] ~ rest] =>
adamc@418 54 tf1 -> tf2 -> tr rest -> tr ([nm] ++ rest))
adamc@643 55 -> tr [] -> r :: {Unit} -> folder r -> $(mapU tf1 r) -> $(mapU tf2 r) -> tr r
adamc@418 56
adamc@418 57 val foldURX2: tf1 :: Type -> tf2 :: Type -> ctx :: {Unit}
adamc@418 58 -> (nm :: Name -> rest :: {Unit}
adamc@629 59 -> [[nm] ~ rest] =>
adamc@418 60 tf1 -> tf2 -> xml ctx [] [])
adamc@643 61 -> r :: {Unit} -> folder r -> $(mapU tf1 r) -> $(mapU tf2 r) -> xml ctx [] []
adamc@418 62
adamc@623 63 val foldR : K --> tf :: (K -> Type) -> tr :: ({K} -> Type)
adamc@623 64 -> (nm :: Name -> t :: K -> rest :: {K}
adamc@629 65 -> [[nm] ~ rest] =>
adamc@355 66 tf t -> tr rest -> tr ([nm = t] ++ rest))
adamc@632 67 -> tr [] -> r :: {K} -> folder r -> $(map tf r) -> tr r
adamc@336 68
adamc@623 69 val foldR2 : K --> tf1 :: (K -> Type) -> tf2 :: (K -> Type)
adamc@623 70 -> tr :: ({K} -> Type)
adamc@623 71 -> (nm :: Name -> t :: K -> rest :: {K}
adamc@629 72 -> [[nm] ~ rest] =>
adamc@623 73 tf1 t -> tf2 t -> tr rest -> tr ([nm = t] ++ rest))
adamc@623 74 -> tr []
adamc@632 75 -> r :: {K} -> folder r -> $(map tf1 r) -> $(map tf2 r) -> tr r
adamc@623 76
adamc@623 77 val foldRX : K --> tf :: (K -> Type) -> ctx :: {Unit}
adamc@623 78 -> (nm :: Name -> t :: K -> rest :: {K}
adamc@629 79 -> [[nm] ~ rest] =>
adamc@623 80 tf t -> xml ctx [] [])
adamc@632 81 -> r :: {K} -> folder r -> $(map tf r) -> xml ctx [] []
adamc@623 82
adamc@623 83 val foldRX2 : K --> tf1 :: (K -> Type) -> tf2 :: (K -> Type) -> ctx :: {Unit}
adamc@623 84 -> (nm :: Name -> t :: K -> rest :: {K}
adamc@629 85 -> [[nm] ~ rest] =>
adamc@623 86 tf1 t -> tf2 t -> xml ctx [] [])
adamc@632 87 -> r :: {K} -> folder r
adamc@623 88 -> $(map tf1 r) -> $(map tf2 r) -> xml ctx [] []
adamc@445 89
adamc@334 90 val queryX : tables ::: {{Type}} -> exps ::: {Type} -> ctx ::: {Unit}
adamc@629 91 -> [tables ~ exps] =>
adamc@632 92 sql_query tables exps
adamc@632 93 -> ($(exps ++ map (fn fields :: {Type} => $fields) tables)
adamc@632 94 -> xml ctx [] [])
adamc@632 95 -> transaction (xml ctx [] [])
adamc@341 96
adamc@469 97 val queryX' : tables ::: {{Type}} -> exps ::: {Type} -> ctx ::: {Unit}
adamc@629 98 -> [tables ~ exps] =>
adamc@632 99 sql_query tables exps
adamc@632 100 -> ($(exps ++ map (fn fields :: {Type} => $fields) tables)
adamc@632 101 -> transaction (xml ctx [] []))
adamc@632 102 -> transaction (xml ctx [] [])
adamc@469 103
adamc@355 104 val oneOrNoRows : tables ::: {{Type}} -> exps ::: {Type}
adamc@629 105 -> [tables ~ exps] =>
adamc@629 106 sql_query tables exps
adamc@629 107 -> transaction
adamc@629 108 (option
adamc@629 109 $(exps
adamc@629 110 ++ map (fn fields :: {Type} => $fields) tables))
adamc@440 111
adamc@440 112 val oneRow : tables ::: {{Type}} -> exps ::: {Type}
adamc@629 113 -> [tables ~ exps] =>
adamc@629 114 sql_query tables exps
adamc@629 115 -> transaction
adamc@629 116 $(exps
adamc@629 117 ++ map (fn fields :: {Type} => $fields) tables)
adamc@629 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 -> sql_exp tables agg exps (option t)
adamc@470 123 -> sql_exp tables agg exps bool
adamc@470 124
adamc@470 125 val eqNullable' : tables ::: {{Type}} -> agg ::: {{Type}} -> exps ::: {Type}
adamc@470 126 -> t ::: Type -> sql_injectable (option t)
adamc@470 127 -> sql_exp tables agg exps (option t)
adamc@470 128 -> option t
adamc@470 129 -> sql_exp tables agg exps bool