diff options
author | Adam Chlipala <adamc@hcoop.net> | 2009-09-15 09:45:46 -0400 |
---|---|---|
committer | Adam Chlipala <adamc@hcoop.net> | 2009-09-15 09:45:46 -0400 |
commit | a8fa8a4567570b1925ff11b17da729ac32cd191e (patch) | |
tree | b0c64428283fba211e8d782b474877c98467593c /demo | |
parent | 89ff99b8cb398180ae3168dec72baa793fe42850 (diff) |
Include 'key' type in Grid
Diffstat (limited to 'demo')
-rw-r--r-- | demo/more/dbgrid.ur | 16 | ||||
-rw-r--r-- | demo/more/grid.ur | 11 | ||||
-rw-r--r-- | demo/more/grid.urs | 7 |
3 files changed, 21 insertions, 13 deletions
diff --git a/demo/more/dbgrid.ur b/demo/more/dbgrid.ur index e25396df..deefd4f1 100644 --- a/demo/more/dbgrid.ur +++ b/demo/more/dbgrid.ur @@ -253,6 +253,8 @@ functor Make(M : sig val aggregates : $(map (aggregateMeta (key ++ row)) aggregates) end) = struct open Grid.Make(struct + fun keyOf r = r --- M.row + val list = query (SELECT * FROM {{M.tab}} AS T) (fn r rs => return (r.T :: rs)) [] val wholeRow = @Folder.concat ! M.keyFolder M.rowFolder @@ -269,7 +271,7 @@ functor Make(M : sig dml (insert M.tab (ensql row)); return row - fun selector (r : $(M.key ++ M.row)) : sql_exp [T = M.key ++ M.row] [] [] bool = + fun selector (r : $M.key) : sql_exp [T = M.key ++ M.row] [] [] bool = foldR2 [rawMeta] [id] [fn key => rest :: {Type} -> [rest ~ key] => sql_exp [T = key ++ rest] [] [] bool] (fn [nm :: Name] [t :: Type] [key :: {Type}] [[nm] ~ key] @@ -278,17 +280,17 @@ functor Make(M : sig [rest :: {Type}] [rest ~ [nm = t] ++ key] => (WHERE T.{nm} = {@sql_inject meta.Inj v} AND {exp [[nm = t] ++ rest] !})) (fn [rest :: {Type}] [rest ~ []] => (WHERE TRUE)) - [_] M.keyFolder (M.raw --- map rawMeta M.row) (r --- M.row) + [_] M.keyFolder (M.raw --- map rawMeta M.row) r [_] ! - fun save {Old = row, New = row'} = + fun save key row = dml (update [M.key ++ M.row] ! - (ensql row') + (ensql row) M.tab - (selector row)) + (selector key)) - fun delete row = - dml (Basis.delete M.tab (selector row)) + fun delete key = + dml (Basis.delete M.tab (selector key)) val cols = M.cols diff --git a/demo/more/grid.ur b/demo/more/grid.ur index 084ddefc..cb836970 100644 --- a/demo/more/grid.ur +++ b/demo/more/grid.ur @@ -17,10 +17,13 @@ con aggregateMeta = fn (row :: Type) (acc :: Type) => functor Make(M : sig type row + type key + val keyOf : row -> key + val list : transaction (list row) val new : transaction row - val save : {Old : row, New : row} -> transaction unit - val delete : row -> transaction unit + val save : key -> row -> transaction unit + val delete : key -> transaction unit con cols :: {(Type * Type)} val cols : $(map (colMeta row) cols) @@ -85,7 +88,7 @@ functor Make(M : sig val delete = Dlist.delete pos; row <- get rowS; - rpc (M.delete row) + rpc (M.delete (M.keyOf row)) val update = set ud True @@ -122,7 +125,7 @@ functor Make(M : sig [[nm] ~ rest] data meta v row' => (meta.Handlers data).Update row' v) row [_] M.folder grid.Cols M.cols cols; - rpc (M.save {Old = row, New = row'}); + rpc (M.save (M.keyOf row) row'); set rowS row'; cols <- makeAll grid.Cols row'; diff --git a/demo/more/grid.urs b/demo/more/grid.urs index 6942d38e..083f458f 100644 --- a/demo/more/grid.urs +++ b/demo/more/grid.urs @@ -17,10 +17,13 @@ con aggregateMeta = fn (row :: Type) (acc :: Type) => functor Make(M : sig type row + type key + val keyOf : row -> key + val list : transaction (list row) val new : transaction row - val save : {Old : row, New : row} -> transaction unit - val delete : row -> transaction unit + val save : key -> row -> transaction unit + val delete : key -> transaction unit con cols :: {(Type * Type)} val cols : $(map (colMeta row) cols) |