Skip to content

Commit 7c437d5

Browse files
authored
Deprecate Set.fold and IntSet.fold (#1049)
They are aliases for foldr and have long been documented as deprecated. Similar functions for Map and IntMap were deprecated in 0.5.8.1.
1 parent 41783ed commit 7c437d5

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

containers-tests/benchmarks/IntSet.hs

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ main = do
2727
, bench "map" $ whnf (IS.map (+ 1)) s
2828
, bench "filter" $ whnf (IS.filter ((== 0) . (`mod` 2))) s
2929
, bench "partition" $ whnf (IS.partition ((== 0) . (`mod` 2))) s
30-
, bench "fold" $ whnf (IS.fold (:) []) s
3130
, bench "delete" $ whnf (del elems) s
3231
, bench "findMin" $ whnf IS.findMin s
3332
, bench "findMax" $ whnf IS.findMax s

containers-tests/benchmarks/Set.hs

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ main = do
2121
, bench "map" $ whnf (S.map (+ 1)) s
2222
, bench "filter" $ whnf (S.filter ((== 0) . (`mod` 2))) s
2323
, bench "partition" $ whnf (S.partition ((== 0) . (`mod` 2))) s
24-
, bench "fold" $ whnf (S.fold (:) []) s
2524
, bench "delete" $ whnf (del elems) s
2625
, bench "findMin" $ whnf S.findMin s
2726
, bench "findMax" $ whnf S.findMax s

containers/changelog.md

+4
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
* Various deprecated functions, whose definitions currently cause type errors,
2929
have been removed. (Soumik Sarkar)
3030

31+
* `Data.Set.fold` and `Data.IntSet.fold` have long been documented as
32+
deprecated and are now marked as such. They will be removed in a future
33+
release.
34+
3135
### Bug fixes
3236

3337
* Make the package compile with MicroHs. (Lennart Augustsson)

containers/src/Data/IntSet/Internal.hs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1180,10 +1180,9 @@ mapMonotonic f = fromDistinctAscList . List.map f . toAscList
11801180
Fold
11811181
--------------------------------------------------------------------}
11821182
-- | \(O(n)\). Fold the elements in the set using the given right-associative
1183-
-- binary operator. This function is an equivalent of 'foldr' and is present
1184-
-- for compatibility only.
1183+
-- binary operator.
11851184
--
1186-
-- /Please note that fold will be deprecated in the future and removed./
1185+
{-# DEPRECATED fold "Use Data.IntSet.foldr instead" #-}
11871186
fold :: (Key -> b -> b) -> b -> IntSet -> b
11881187
fold = foldr
11891188
{-# INLINE fold #-}

containers/src/Data/Set/Internal.hs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1027,10 +1027,9 @@ mapMonotonic f (Bin sz x l r) = Bin sz (f x) (mapMonotonic f l) (mapMonotonic f
10271027
Fold
10281028
--------------------------------------------------------------------}
10291029
-- | \(O(n)\). Fold the elements in the set using the given right-associative
1030-
-- binary operator. This function is an equivalent of 'foldr' and is present
1031-
-- for compatibility only.
1030+
-- binary operator.
10321031
--
1033-
-- /Please note that fold will be deprecated in the future and removed./
1032+
{-# DEPRECATED fold "Use Data.Set.foldr instead" #-}
10341033
fold :: (a -> b -> b) -> b -> Set a -> b
10351034
fold = foldr
10361035
{-# INLINE fold #-}

0 commit comments

Comments
 (0)