comparison demo/more/grid.ur @ 936:6966d98c80b5

Include 'key' type in Grid
author Adam Chlipala <adamc@hcoop.net>
date Tue, 15 Sep 2009 09:45:46 -0400
parents 2422360c78a3
children 37dd42935dad
comparison
equal deleted inserted replaced
935:2422360c78a3 936:6966d98c80b5
15 Step : row -> acc -> acc, 15 Step : row -> acc -> acc,
16 Display : acc -> xbody} 16 Display : acc -> xbody}
17 17
18 functor Make(M : sig 18 functor Make(M : sig
19 type row 19 type row
20 type key
21 val keyOf : row -> key
22
20 val list : transaction (list row) 23 val list : transaction (list row)
21 val new : transaction row 24 val new : transaction row
22 val save : {Old : row, New : row} -> transaction unit 25 val save : key -> row -> transaction unit
23 val delete : row -> transaction unit 26 val delete : key -> transaction unit
24 27
25 con cols :: {(Type * Type)} 28 con cols :: {(Type * Type)}
26 val cols : $(map (colMeta row) cols) 29 val cols : $(map (colMeta row) cols)
27 30
28 val folder : folder cols 31 val folder : folder cols
83 {Dlist.render (fn {Row = rowS, Cols = colsS, Updating = ud} pos => 86 {Dlist.render (fn {Row = rowS, Cols = colsS, Updating = ud} pos =>
84 let 87 let
85 val delete = 88 val delete =
86 Dlist.delete pos; 89 Dlist.delete pos;
87 row <- get rowS; 90 row <- get rowS;
88 rpc (M.delete row) 91 rpc (M.delete (M.keyOf row))
89 92
90 val update = set ud True 93 val update = set ud True
91 94
92 val cancel = 95 val cancel =
93 set ud False; 96 set ud False;
120 (fn [nm :: Name] [t :: (Type * Type)] 123 (fn [nm :: Name] [t :: (Type * Type)]
121 [rest :: {(Type * Type)}] 124 [rest :: {(Type * Type)}]
122 [[nm] ~ rest] data meta v row' => 125 [[nm] ~ rest] data meta v row' =>
123 (meta.Handlers data).Update row' v) 126 (meta.Handlers data).Update row' v)
124 row [_] M.folder grid.Cols M.cols cols; 127 row [_] M.folder grid.Cols M.cols cols;
125 rpc (M.save {Old = row, New = row'}); 128 rpc (M.save (M.keyOf row) row');
126 set rowS row'; 129 set rowS row';
127 130
128 cols <- makeAll grid.Cols row'; 131 cols <- makeAll grid.Cols row';
129 set colsS cols 132 set colsS cols
130 in 133 in