on develop help sign in
Merge pull request #185 from reflex-frp/safe-swap-rows
1cdea31Ryan Trinkle
reflex-dom/benchmarks/krausest.hs+2−1
@@ -120,8 +120,9 @@ filterByIndex :: (Int -> Bool) -> [a] -> [a]
120filterByIndex p = map snd . filter (\(i, _) -> p i) . zip [0..]
120filterByIndex p = map snd . filter (\(i, _) -> p i) . zip [0..]
121
121
122swapRows :: (RowIndex, RowIndex) -> (Model, Table) -> (Model, TableDiff)
122swapRows :: (RowIndex, RowIndex) -> (Model, Table) -> (Model, TableDiff)
123−swapRows (a, b) (m, t) = (m, PatchIntMap $ point a b <> point b a)
123+swapRows (a, b) (m, t) = (m, PatchIntMap $ if max a b < length t then swap else empty)
124 where
124 where
125+ swap = point a b <> point b a
125 point x y = singleton (fst (val x)) $ Just $ snd $ val y
126 point x y = singleton (fst (val x)) $ Just $ snd $ val y
126 val = (assocs t !!)
127 val = (assocs t !!)
127
128