comparison demo/more/grid.ur @ 954:2a50da66ffd8

Basic tail recursion introduction seems to be working
author Adam Chlipala <adamc@hcoop.net>
date Thu, 17 Sep 2009 16:35:11 -0400
parents 301530da2062
children 3aaac251a5af
comparison
equal deleted inserted replaced
953:301530da2062 954:2a50da66ffd8
57 Updating : source bool, 57 Updating : source bool,
58 Selected : source bool}, 58 Selected : source bool},
59 Selection : source bool, 59 Selection : source bool,
60 Filters : $(map thd3 M.cols)} 60 Filters : $(map thd3 M.cols)}
61 61
62 fun addRow cols rows row = 62 fun newRow cols row =
63 rowS <- source row; 63 rowS <- source row;
64 cols <- makeAll cols row; 64 cols <- makeAll cols row;
65 colsS <- source cols; 65 colsS <- source cols;
66 ud <- source False; 66 ud <- source False;
67 sd <- source False; 67 sd <- source False;
68 Monad.ignore (Dlist.append rows {Row = rowS, 68 return {Row = rowS,
69 Cols = colsS, 69 Cols = colsS,
70 Updating = ud, 70 Updating = ud,
71 Selected = sd}) 71 Selected = sd}
72
73 fun addRow cols rows row =
74 r <- newRow cols row;
75 Monad.ignore (Dlist.append rows r)
72 76
73 val grid = 77 val grid =
74 cols <- Monad.mapR [colMeta M.row] [fst3] 78 cols <- Monad.mapR [colMeta M.row] [fst3]
75 (fn [nm :: Name] [p :: (Type * Type * Type)] meta => meta.Initialize) 79 (fn [nm :: Name] [p :: (Type * Type * Type)] meta => meta.Initialize)
76 [_] M.folder M.cols; 80 [_] M.folder M.cols;
89 Filters = filters} 93 Filters = filters}
90 94
91 fun sync {Cols = cols, Rows = rows, ...} = 95 fun sync {Cols = cols, Rows = rows, ...} =
92 Dlist.clear rows; 96 Dlist.clear rows;
93 init <- rpc M.list; 97 init <- rpc M.list;
94 List.app (addRow cols rows) init 98 rs <- List.mapM (newRow cols) init;
99 Dlist.replace rows rs
95 100
96 fun render grid = <xml> 101 fun render grid = <xml>
97 <table class={tabl}> 102 <table class={tabl}>
98 <tr class={tr}> 103 <tr class={tr}>
99 <th/> <th/> <th/> 104 <th/> <th/> <th/>