Skip to content

Commit

Permalink
Changes after review 4
Browse files Browse the repository at this point in the history
  • Loading branch information
flip111 committed Nov 20, 2024
1 parent 2279b03 commit d5053e6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
20 changes: 10 additions & 10 deletions containers-tests/tests/intmap-properties.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1514,17 +1514,17 @@ prop_filter p ys = length ys > 0 ==>
in valid m .&&.
m === fromList (List.filter (apply p . snd) xs)

prop_filterKeys :: Fun Int Bool -> [(Int, Int)] -> Property
prop_filterKeys p ys = length ys > 0 ==>
let xs = List.nubBy ((==) `on` fst) ys
m = fromList xs
in filterKeys (apply p) m == fromList (List.filter (apply p . fst) xs)
prop_filterKeys :: Fun Int Bool -> IMap -> Property
prop_filterKeys fun m =
valid m' .&&. toList m' === Prelude.filter (apply fun . fst) (toList m)
where
m' = filterKeys (apply fun) m

prop_filterWithKey :: Fun (Int, Int) Bool -> [(Int, Int)] -> Property
prop_filterWithKey p ys = length ys > 0 ==>
let xs = List.nubBy ((==) `on` fst) ys
m = fromList xs
in filterWithKey (\k v -> apply p (k, v)) m == fromList (List.filter (\(k, v) -> apply p (k, v)) xs)
prop_filterWithKey :: Fun (Int, Int) Bool -> IMap -> Property
prop_filterWithKey fun m =
valid m' .&&. toList m' === Prelude.filter (apply fun) (toList m)
where
m' = filterWithKey (apply2 fun) m

prop_partition :: Fun Int Bool -> [(Int, Int)] -> Property
prop_partition p ys = length ys > 0 ==>
Expand Down
1 change: 0 additions & 1 deletion containers/src/Data/IntMap/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2642,7 +2642,6 @@ filter p m
-- | \(O(n)\). Filter all keys that satisfy some predicate.
--
-- > filterKeys (> 4) (fromList [(5,"a"), (3,"b")]) == singleton 5 "a"
-- > filterKeys (> 4) == filterWithKey (\k _ -> k > 4)
--
-- @
-- filterKeys p = 'filterWithKey' (\k _ -> p k)
Expand Down

0 comments on commit d5053e6

Please sign in to comment.