adamc@623: (** Row folding *) adamc@623: adamc@623: con folder = K ==> fn r :: {K} => adamc@623: tf :: ({K} -> Type) adamc@623: -> (nm :: Name -> v :: K -> r :: {K} -> tf r adamc@623: -> fn [[nm] ~ r] => tf ([nm = v] ++ r)) adamc@623: -> tf [] -> tf r adamc@623: adamc@623: adamc@422: val not : bool -> bool adamc@422: adamc@329: con idT = fn t :: Type => t adamc@329: con record = fn t :: {Type} => $t adamc@339: con fstTT = fn t :: (Type * Type) => t.1 adamc@339: con sndTT = fn t :: (Type * Type) => t.2 adamc@445: con fstTTT = fn t :: (Type * Type * Type) => t.1 adamc@445: con sndTTT = fn t :: (Type * Type * Type) => t.2 adamc@445: con thdTTT = fn t :: (Type * Type * Type) => t.3 adamc@329: adamc@621: con mapUT = fn f :: Type => map (fn _ :: Unit => f) adamc@445: adamc@339: con ex = fn tf :: (Type -> Type) => adamc@355: res ::: Type -> (choice :: Type -> tf choice -> res) -> res adamc@339: adamc@339: val ex : tf :: (Type -> Type) -> choice :: Type -> tf choice -> ex tf adamc@339: adamc@325: val compose : t1 ::: Type -> t2 ::: Type -> t3 ::: Type adamc@355: -> (t2 -> t3) -> (t1 -> t2) -> (t1 -> t3) adamc@325: adamc@325: val txt : t ::: Type -> ctx ::: {Unit} -> use ::: {Type} -> show t -> t adamc@355: -> xml ctx use [] adamc@329: adamc@411: val foldUR : tf :: Type -> tr :: ({Unit} -> Type) adamc@411: -> (nm :: Name -> rest :: {Unit} adamc@411: -> fn [[nm] ~ rest] => adamc@411: tf -> tr rest -> tr ([nm] ++ rest)) adamc@623: -> tr [] -> r ::: {Unit} -> folder r -> $(mapUT tf r) -> tr r adamc@411: adamc@418: val foldUR2 : tf1 :: Type -> tf2 :: Type -> tr :: ({Unit} -> Type) adamc@418: -> (nm :: Name -> rest :: {Unit} adamc@418: -> fn [[nm] ~ rest] => adamc@418: tf1 -> tf2 -> tr rest -> tr ([nm] ++ rest)) adamc@623: -> tr [] -> r ::: {Unit} -> folder r -> $(mapUT tf1 r) -> $(mapUT tf2 r) -> tr r adamc@418: adamc@418: val foldURX2: tf1 :: Type -> tf2 :: Type -> ctx :: {Unit} adamc@418: -> (nm :: Name -> rest :: {Unit} adamc@418: -> fn [[nm] ~ rest] => adamc@418: tf1 -> tf2 -> xml ctx [] []) adamc@623: -> r ::: {Unit} -> folder r -> $(mapUT tf1 r) -> $(mapUT tf2 r) -> xml ctx [] [] adamc@418: adamc@623: val foldR : K --> tf :: (K -> Type) -> tr :: ({K} -> Type) adamc@623: -> (nm :: Name -> t :: K -> rest :: {K} adamc@355: -> fn [[nm] ~ rest] => adamc@355: tf t -> tr rest -> tr ([nm = t] ++ rest)) adamc@623: -> tr [] -> r ::: {K} -> folder r -> $(map tf r) -> tr r adamc@336: adamc@623: val foldR2 : K --> tf1 :: (K -> Type) -> tf2 :: (K -> Type) adamc@623: -> tr :: ({K} -> Type) adamc@623: -> (nm :: Name -> t :: K -> rest :: {K} adamc@623: -> fn [[nm] ~ rest] => adamc@623: tf1 t -> tf2 t -> tr rest -> tr ([nm = t] ++ rest)) adamc@623: -> tr [] adamc@623: -> r ::: {K} -> folder r -> $(map tf1 r) -> $(map tf2 r) -> tr r adamc@623: adamc@623: val foldRX : K --> tf :: (K -> Type) -> ctx :: {Unit} adamc@623: -> (nm :: Name -> t :: K -> rest :: {K} adamc@623: -> fn [[nm] ~ rest] => adamc@623: tf t -> xml ctx [] []) adamc@623: -> r ::: {K} -> folder r -> $(map tf r) -> xml ctx [] [] adamc@623: adamc@623: val foldRX2 : K --> tf1 :: (K -> Type) -> tf2 :: (K -> Type) -> ctx :: {Unit} adamc@623: -> (nm :: Name -> t :: K -> rest :: {K} adamc@355: -> fn [[nm] ~ rest] => adamc@623: tf1 t -> tf2 t -> xml ctx [] []) adamc@623: -> r ::: {K} -> folder r adamc@623: -> $(map tf1 r) -> $(map tf2 r) -> xml ctx [] [] adamc@445: adamc@334: val queryX : tables ::: {{Type}} -> exps ::: {Type} -> ctx ::: {Unit} adamc@355: -> sql_query tables exps adamc@355: -> fn [tables ~ exps] => adamc@621: ($(exps ++ map (fn fields :: {Type} => $fields) tables) adamc@355: -> xml ctx [] []) adamc@355: -> transaction (xml ctx [] []) adamc@341: adamc@469: val queryX' : tables ::: {{Type}} -> exps ::: {Type} -> ctx ::: {Unit} adamc@469: -> sql_query tables exps adamc@469: -> fn [tables ~ exps] => adamc@621: ($(exps ++ map (fn fields :: {Type} => $fields) tables) adamc@469: -> transaction (xml ctx [] [])) adamc@469: -> transaction (xml ctx [] []) adamc@469: adamc@355: val oneOrNoRows : tables ::: {{Type}} -> exps ::: {Type} adamc@355: -> sql_query tables exps adamc@355: -> fn [tables ~ exps] => adamc@355: transaction adamc@355: (option adamc@355: $(exps adamc@621: ++ map (fn fields :: {Type} => $fields) tables)) adamc@440: adamc@440: val oneRow : tables ::: {{Type}} -> exps ::: {Type} adamc@440: -> sql_query tables exps adamc@440: -> fn [tables ~ exps] => adamc@440: transaction adamc@440: $(exps adamc@621: ++ map (fn fields :: {Type} => $fields) tables) adamc@470: adamc@470: val eqNullable : tables ::: {{Type}} -> agg ::: {{Type}} -> exps ::: {Type} adamc@470: -> t ::: Type -> sql_injectable (option t) adamc@470: -> sql_exp tables agg exps (option t) adamc@470: -> sql_exp tables agg exps (option t) adamc@470: -> sql_exp tables agg exps bool adamc@470: adamc@470: val eqNullable' : tables ::: {{Type}} -> agg ::: {{Type}} -> exps ::: {Type} adamc@470: -> t ::: Type -> sql_injectable (option t) adamc@470: -> sql_exp tables agg exps (option t) adamc@470: -> option t adamc@470: -> sql_exp tables agg exps bool