# HG changeset patch # User Adam Chlipala # Date 1323632658 18000 # Node ID 95958369216685843d28b7116696ce5de7dc62b0 # Parent 6ebc2ca594b783e92f169dcd8290c55b886c8bbf Reorder arguments for better partial application diff -r 6ebc2ca594b7 -r 959583692166 sql.ur --- a/sql.ur Sun Dec 11 14:04:34 2011 -0500 +++ b/sql.ur Sun Dec 11 14:44:18 2011 -0500 @@ -29,10 +29,10 @@ fun insertIfMissing [keyCols ::: {Type}] [otherCols ::: {Type}] [otherKeys ::: {{Unit}}] [keyCols ~ otherCols] [[Pkey] ~ otherKeys] + (kfl : folder keyCols) (kinj : $(map sql_injectable keyCols)) + (ofl : folder otherCols) (oinj : $(map sql_injectable otherCols)) (t : sql_table (keyCols ++ otherCols) ([Pkey = map (fn _ => ()) keyCols] ++ otherKeys)) (vs : $(keyCols ++ otherCols)) - (kfl : folder keyCols) (kinj : $(map sql_injectable keyCols)) - (ofl : folder otherCols) (oinj : $(map sql_injectable otherCols)) : transaction bool = alreadyThere <- oneRowE1 (SELECT COUNT( * ) > 0 FROM t @@ -46,6 +46,7 @@ fun deleteByKey [keyCols ::: {Type}] [otherCols ::: {Type}] [otherKeys ::: {{Unit}}] [keyCols ~ otherCols] [[Pkey] ~ otherKeys] + (kfl : folder keyCols) (kinj : $(map sql_injectable keyCols)) (t : sql_table (keyCols ++ otherCols) ([Pkey = map (fn _ => ()) keyCols] ++ otherKeys)) - (vs : $keyCols) (kfl : folder keyCols) (kinj : $(map sql_injectable keyCols)) = + (vs : $keyCols) = dml (delete t (@selector [#T] ! kfl kinj vs)) diff -r 6ebc2ca594b7 -r 959583692166 sql.urs --- a/sql.urs Sun Dec 11 14:04:34 2011 -0500 +++ b/sql.urs Sun Dec 11 14:44:18 2011 -0500 @@ -18,16 +18,17 @@ val insertIfMissing : keyCols ::: {Type} -> otherCols ::: {Type} -> otherKeys ::: {{Unit}} -> [keyCols ~ otherCols] => [[Pkey] ~ otherKeys] - => sql_table (keyCols ++ otherCols) ([Pkey = map (fn _ => ()) keyCols] ++ otherKeys) + => folder keyCols -> $(map sql_injectable keyCols) + -> folder otherCols -> $(map sql_injectable otherCols) + -> sql_table (keyCols ++ otherCols) ([Pkey = map (fn _ => ()) keyCols] ++ otherKeys) -> $(keyCols ++ otherCols) - -> folder keyCols -> $(map sql_injectable keyCols) - -> folder otherCols -> $(map sql_injectable otherCols) -> transaction bool (* Insert a row into an SQL table if its key isn't already present, returning [False] iff the key was already present *) val deleteByKey : keyCols ::: {Type} -> otherCols ::: {Type} -> otherKeys ::: {{Unit}} -> [keyCols ~ otherCols] => [[Pkey] ~ otherKeys] - => sql_table (keyCols ++ otherCols) ([Pkey = map (fn _ => ()) keyCols] ++ otherKeys) - -> $keyCols -> folder keyCols -> $(map sql_injectable keyCols) + => folder keyCols -> $(map sql_injectable keyCols) + -> sql_table (keyCols ++ otherCols) ([Pkey = map (fn _ => ()) keyCols] ++ otherKeys) + -> $keyCols -> transaction {} (* Delete a row from a table by matching its primary key against a given record. *)