Skip to content

Commit 763ba83

Browse files
committed
Remove catMaybes.
1 parent af0b169 commit 763ba83

File tree

19 files changed

+3
-115
lines changed

19 files changed

+3
-115
lines changed

containers-tests/tests/intmap-properties.hs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import Control.Monad ((<=<))
1818
import qualified Data.Either as Either
1919
import qualified Data.Foldable as Foldable
2020
import Data.Monoid
21-
import Data.Maybe hiding (catMaybes, mapMaybe)
21+
import Data.Maybe hiding (mapMaybe)
2222
import qualified Data.Maybe as Maybe (mapMaybe)
2323
import Data.Ord
2424
import Data.Foldable (foldMap)
@@ -110,7 +110,6 @@ main = defaultMain $ testGroup "intmap-properties"
110110
, testCase "filterWithKey" test_filterWithKey
111111
, testCase "partition" test_partition
112112
, testCase "partitionWithKey" test_partitionWithKey
113-
, testCase "catMaybes" test_catMaybes
114113
, testCase "mapMaybe" test_mapMaybe
115114
, testCase "mapMaybeWithKey" test_mapMaybeWithKey
116115
, testCase "mapEither" test_mapEither
@@ -190,7 +189,6 @@ main = defaultMain $ testGroup "intmap-properties"
190189
, testProperty "filterKeys" prop_filterKeys
191190
, testProperty "filterWithKey" prop_filterWithKey
192191
, testProperty "partition" prop_partition
193-
, testProperty "catMaybes" prop_catMaybes
194192
, testProperty "mapMaybe" prop_mapMaybe
195193
, testProperty "takeWhileAntitone" prop_takeWhileAntitone
196194
, testProperty "dropWhileAntitone" prop_dropWhileAntitone
@@ -943,10 +941,6 @@ test_partitionWithKey = do
943941
partitionWithKey (\ k _ -> k < 7) (fromList [(5,"a"), (-3,"b")]) @?= (fromList [(-3, "b"), (5, "a")], empty)
944942
partitionWithKey (\ k _ -> k > 7) (fromList [(5,"a"), (-3,"b")]) @?= (empty, fromList [(-3, "b"), (5, "a")])
945943

946-
test_catMaybes :: Assertion
947-
test_catMaybes = do
948-
catMaybes (fromList [(5,Just "a"), (3,Nothing)]) @?= singleton 5 "a"
949-
950944
test_mapMaybe :: Assertion
951945
test_mapMaybe = do
952946
mapMaybe f (fromList [(5,"a"), (3,"b")]) @?= singleton 5 "new a"
@@ -1559,13 +1553,6 @@ prop_filterWithKey fun m =
15591553
where
15601554
m' = filterWithKey (applyFun2 fun) m
15611555

1562-
prop_catMaybes :: IntMap (Maybe A) -> Property
1563-
prop_catMaybes m =
1564-
valid m' .&&.
1565-
toList m' === Maybe.mapMaybe (\(k,x) -> (,) k <$> x) (toList m)
1566-
where
1567-
m' = catMaybes m
1568-
15691556
prop_mapMaybe :: Fun Int (Maybe Bool) -> IMap -> Property
15701557
prop_mapMaybe f m =
15711558
valid m' .&&.

containers-tests/tests/intmap-strictness.hs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -618,12 +618,6 @@ prop_lazyMapKeysWith fun kfun m = isNotBottomProp (L.mapKeysWith f kf m)
618618
f = coerce (applyFunc2 fun) :: A -> A -> A
619619
kf = applyFunc kfun
620620

621-
prop_strictCatMaybes :: IntMap (Maybe (Bot A)) -> Property
622-
prop_strictCatMaybes m = isBottom (M.catMaybes m) === isBottom (M.mapMaybe id m)
623-
624-
prop_lazyCatMaybes :: IntMap (Maybe (Bot A)) -> Property
625-
prop_lazyCatMaybes m = isNotBottomProp (L.catMaybes m)
626-
627621
prop_strictMapMaybe :: Func A (Maybe (Bot B)) -> IntMap A -> Property
628622
prop_strictMapMaybe fun m =
629623
isBottom (M.mapMaybe f m) === isBottom (M.mapMaybeWithKey (const f) m)
@@ -1056,7 +1050,6 @@ tests =
10561050
, testPropStrictLazy "mapAccumWithKey" prop_strictMapAccumWithKey prop_lazyMapAccumWithKey
10571051
, testPropStrictLazy "mapAccumRWithKey" prop_strictMapAccumRWithKey prop_lazyMapAccumRWithKey
10581052
, testPropStrictLazy "mapKeysWith" prop_strictMapKeysWith prop_lazyMapKeysWith
1059-
, testPropStrictLazy "catMaybes" prop_strictCatMaybes prop_lazyCatMaybes
10601053
, testPropStrictLazy "mapMaybe" prop_strictMapMaybe prop_lazyMapMaybe
10611054
, testPropStrictLazy "mapMaybeWithKey" prop_strictMapMaybeWithKey prop_lazyMapMaybeWithKey
10621055
, testPropStrictLazy "mapEither" prop_strictMapEither prop_lazyMapEither

containers-tests/tests/map-properties.hs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import Control.Monad ((<=<))
1818
import qualified Data.Either as Either
1919
import Data.Functor.Identity (Identity(Identity, runIdentity))
2020
import Data.Monoid
21-
import Data.Maybe hiding (catMaybes, mapMaybe)
21+
import Data.Maybe hiding (mapMaybe)
2222
import qualified Data.Maybe as Maybe (mapMaybe)
2323
import Data.Ord
2424
import Data.Semigroup (Arg(..))
@@ -124,7 +124,6 @@ main = defaultMain $ testGroup "map-properties"
124124
, testCase "filterWithKey" test_filterWithKey
125125
, testCase "partition" test_partition
126126
, testCase "partitionWithKey" test_partitionWithKey
127-
, testCase "catMaybes" test_catMaybes
128127
, testCase "mapMaybe" test_mapMaybe
129128
, testCase "mapMaybeWithKey" test_mapMaybeWithKey
130129
, testCase "mapEither" test_mapEither
@@ -297,7 +296,6 @@ main = defaultMain $ testGroup "map-properties"
297296
, testProperty "differenceWith" prop_differenceWith
298297
, testProperty "differenceWithKey" prop_differenceWithKey
299298
, testProperty "partitionWithKey" prop_partitionWithKey
300-
, testProperty "catMaybes" prop_catMaybes
301299
, testProperty "mapMaybe" prop_mapMaybe
302300
, testProperty "mapMaybeWithKey" prop_mapMaybeWithKey
303301
, testProperty "traverseMaybeWithKey" prop_traverseMaybeWithKey
@@ -864,9 +862,6 @@ test_partitionWithKey = do
864862
partitionWithKey (\ k _ -> k < 7) (fromList [(5,"a"), (3,"b")]) @?= (fromList [(3, "b"), (5, "a")], empty)
865863
partitionWithKey (\ k _ -> k > 7) (fromList [(5,"a"), (3,"b")]) @?= (empty, fromList [(3, "b"), (5, "a")])
866864

867-
test_catMaybes :: Assertion
868-
test_catMaybes = catMaybes (fromList [(5,Just "a"), (3,Nothing)]) @?= singleton 5 "a"
869-
870865
test_mapMaybe :: Assertion
871866
test_mapMaybe = mapMaybe f (fromList [(5,"a"), (3,"b")]) @?= singleton 5 "new a"
872867
where
@@ -1965,13 +1960,6 @@ prop_partitionWithKey f m =
19651960
where
19661961
(m1, m2) = partitionWithKey (applyFun2 f) m
19671962

1968-
prop_catMaybes :: Map Int (Maybe A) -> Property
1969-
prop_catMaybes m =
1970-
valid m' .&&.
1971-
toList m' === Maybe.mapMaybe (\(k,x) -> (,) k <$> x) (toList m)
1972-
where
1973-
m' = catMaybes m
1974-
19751963
prop_mapMaybe :: Fun A (Maybe B) -> Map Int A -> Property
19761964
prop_mapMaybe f m =
19771965
valid m' .&&.

containers-tests/tests/map-strictness.hs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -755,12 +755,6 @@ prop_lazyMapKeysWith fun kfun m = isNotBottomProp (L.mapKeysWith f kf m)
755755
f = coerce (applyFunc2 fun) :: A -> A -> A
756756
kf = applyFunc kfun
757757

758-
prop_strictCatMaybes :: Map OrdA (Maybe (Bot A)) -> Property
759-
prop_strictCatMaybes m = isBottom (M.catMaybes m) === isBottom (M.mapMaybe id m)
760-
761-
prop_lazyCatMaybes :: Map OrdA (Maybe (Bot A)) -> Property
762-
prop_lazyCatMaybes m = isNotBottomProp (L.catMaybes m)
763-
764758
prop_strictMapMaybe :: Func A (Maybe (Bot B)) -> Map OrdA A -> Property
765759
prop_strictMapMaybe fun m =
766760
isBottom (M.mapMaybe f m) === isBottom (M.mapMaybeWithKey (const f) m)
@@ -1199,7 +1193,6 @@ tests =
11991193
, testPropStrictLazy "mapAccumWithKey" prop_strictMapAccumWithKey prop_lazyMapAccumWithKey
12001194
, testPropStrictLazy "mapAccumRWithKey" prop_strictMapAccumRWithKey prop_lazyMapAccumRWithKey
12011195
, testPropStrictLazy "mapKeysWith" prop_strictMapKeysWith prop_lazyMapKeysWith
1202-
, testPropStrictLazy "catMaybes" prop_strictCatMaybes prop_lazyCatMaybes
12031196
, testPropStrictLazy "mapMaybe" prop_strictMapMaybe prop_lazyMapMaybe
12041197
, testPropStrictLazy "mapMaybeWithKey" prop_strictMapMaybeWithKey prop_lazyMapMaybeWithKey
12051198
, testPropStrictLazy "mapEither" prop_strictMapEither prop_lazyMapEither

containers-tests/tests/seq-properties.hs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ main = defaultMain $ testGroup "seq-properties"
101101
, testProperty "breakr" prop_breakr
102102
, testProperty "partition" prop_partition
103103
, testProperty "filter" prop_filter
104-
, testProperty "catMaybes" prop_catMaybes
105104
, testProperty "mapMaybe" prop_mapMaybe
106105
, testProperty "sort" prop_sort
107106
, testProperty "sortStable" prop_sortStable
@@ -556,10 +555,6 @@ prop_filter (Positive n) xs =
556555
toList' (filter p xs) ~= Prelude.filter p (toList xs)
557556
where p x = x `mod` n == 0
558557

559-
prop_catMaybes :: Seq (Maybe Int) -> Bool
560-
prop_catMaybes xs =
561-
toList' (catMaybes xs) ~= Maybe.catMaybes (toList xs)
562-
563558
prop_mapMaybe :: Fun Int (Maybe Int) -> Seq Int -> Bool
564559
prop_mapMaybe f xs =
565560
toList' (mapMaybe (applyFun f) xs) ~= Maybe.mapMaybe (applyFun f) (toList xs)

containers-tests/tests/set-properties.hs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ main = defaultMain $ testGroup "set-properties"
9999
, testProperty "prop_splitRoot" prop_splitRoot
100100
, testProperty "prop_partition" prop_partition
101101
, testProperty "prop_filter" prop_filter
102-
, testProperty "prop_catMaybes" prop_catMaybes
103102
, testProperty "prop_mapMaybe" prop_mapMaybe
104103
, testProperty "takeWhileAntitone" prop_takeWhileAntitone
105104
, testProperty "dropWhileAntitone" prop_dropWhileAntitone
@@ -647,10 +646,6 @@ prop_partition s i = case partition odd s of
647646
prop_filter :: Set Int -> Int -> Bool
648647
prop_filter s i = partition odd s == (filter odd s, filter even s)
649648

650-
prop_catMaybes :: MaybeIntSet -> Bool
651-
prop_catMaybes (MaybeIntSet s) =
652-
toList (catMaybes s) == Maybe.catMaybes (toList s)
653-
654649
prop_mapMaybe :: Fun Int (Maybe Int) -> Set Int -> Property
655650
prop_mapMaybe f s =
656651
let mapped = mapMaybe (applyFun f) s

containers/changelog.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
* Add `compareSize` for `IntSet` and `IntMap`. (Soumik Sarkar)
88
([#1135](https://github.com/haskell/containers/pull/1135))
99

10-
* Add `catMaybes` for `Seq`, `Set`, `Map` and `IntMap`; and `mapMaybe` for
11-
`Seq`, `Set` and `IntSet`. (Phil Hazelden)
10+
* Add `mapMaybe` for `Seq`, `Set` and `IntSet`. (Phil Hazelden)
1211
([#1159](https://github.com/haskell/containers/pull/1159)
1312

1413
### Performance improvements

containers/src/Data/IntMap/Internal.hs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,6 @@ module Data.IntMap.Internal (
250250
, dropWhileAntitone
251251
, spanAntitone
252252

253-
, catMaybes
254253
, mapMaybe
255254
, mapMaybeWithKey
256255
, mapEither
@@ -2878,15 +2877,6 @@ spanAntitone predicate t =
28782877
| otherwise = (Nil :*: t')
28792878
go _ Nil = (Nil :*: Nil)
28802879

2881-
-- | \(O(n)\). Remove 'Nothing's and retain the 'Just' values.
2882-
--
2883-
-- > catMaybes (fromList [(5,Just "a"), (3,Nothing)]) == singleton 5 "a"
2884-
--
2885-
-- @since FIXME
2886-
2887-
catMaybes :: IntMap (Maybe a) -> IntMap a
2888-
catMaybes = mapMaybe id
2889-
28902880
-- | \(O(n)\). Map values and collect the 'Just' results.
28912881
--
28922882
-- > let f x = if x == "a" then Just "new a" else Nothing

containers/src/Data/IntMap/Lazy.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,6 @@ module Data.IntMap.Lazy (
234234
, dropWhileAntitone
235235
, spanAntitone
236236

237-
, catMaybes
238237
, mapMaybe
239238
, mapMaybeWithKey
240239
, mapEither

containers/src/Data/IntMap/Strict.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,6 @@ module Data.IntMap.Strict (
252252
, dropWhileAntitone
253253
, spanAntitone
254254

255-
, catMaybes
256255
, mapMaybe
257256
, mapMaybeWithKey
258257
, mapEither

0 commit comments

Comments
 (0)