File tree Expand file tree Collapse file tree 2 files changed +7
-0
lines changed
containers-tests/benchmarks Expand file tree Collapse file tree 2 files changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,8 @@ main = do
2727 , bench " lookup present" $ whnf (lookup evens) m_even
2828 , bench " map" $ whnf (M. map (+ 1 )) m
2929 , bench " map really" $ nf (M. map (+ 2 )) m
30+ , bench " filter" $ whnf (M. filter even ) m
31+ , bench " filter really" $ nf (M. filter even ) m
3032 , bench " <$" $ whnf ((1 :: Int ) <$ ) m
3133 , bench " <$ really" $ nf ((2 :: Int ) <$ ) m
3234 , bench " alterF lookup absent" $ whnf (atLookup evens) m_odd
Original file line number Diff line number Diff line change @@ -2966,6 +2966,9 @@ filter p m
29662966
29672967filterWithKey :: (k -> a -> Bool ) -> Map k a -> Map k a
29682968filterWithKey _ Tip = Tip
2969+ filterWithKey p t@ (Bin 1 kx x _ _)
2970+ | p kx x = t
2971+ | otherwise = Tip
29692972filterWithKey p t@ (Bin _ kx x l r)
29702973 | p kx x = if pl `ptrEq` l && pr `ptrEq` r
29712974 then t
@@ -2978,6 +2981,8 @@ filterWithKey p t@(Bin _ kx x l r)
29782981-- predicate.
29792982filterWithKeyA :: Applicative f => (k -> a -> f Bool ) -> Map k a -> f (Map k a )
29802983filterWithKeyA _ Tip = pure Tip
2984+ filterWithKeyA p t@ (Bin 1 kx x _ _) =
2985+ fmap (bool Tip t) (p kx x)
29812986filterWithKeyA p t@ (Bin _ kx x l r) =
29822987 liftA3 combine (filterWithKeyA p l) (p kx x) (filterWithKeyA p r)
29832988 where
You can’t perform that action at this time.
0 commit comments