Mercurial > meta
changeset 16:959583692166
Reorder arguments for better partial application
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Sun, 11 Dec 2011 14:44:18 -0500 |
parents | 6ebc2ca594b7 |
children | 1a915f89f23a |
files | sql.ur sql.urs |
diffstat | 2 files changed, 10 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- 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))
--- 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. *)