Skip to content

Commit

Permalink
Merge pull request #323 from treeowl/deprecate-ancient
Browse files Browse the repository at this point in the history
Deprecate some functions in Data.Map
  • Loading branch information
treeowl authored Aug 31, 2016
2 parents 122ddc7 + 989017b commit eed0db8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 20 deletions.
30 changes: 10 additions & 20 deletions Data/Map.hs
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,14 @@ import Prelude hiding (foldr)
import Data.Map.Lazy
import qualified Data.Map.Strict as Strict

-- | /Deprecated./ As of version 0.5, replaced by 'Data.Map.Strict.insertWith'.
--
-- /O(log n)/. Same as 'insertWith', but the value being inserted to the map is
-- | /O(log n)/. Same as 'insertWith', but the value being inserted to the map is
-- evaluated to WHNF beforehand.
--
-- For example, to update a counter:
--
-- > insertWith' (+) k 1 m
--

{-# DEPRECATED insertWith' "As of version 0.5, replaced by 'Data.Map.Strict.insertWith'." #-}
insertWith' :: Ord k => (a -> a -> a) -> k -> a -> Map k a -> Map k a
insertWith' = Strict.insertWith
#if __GLASGOW_HASKELL__
Expand All @@ -90,12 +88,9 @@ insertWith' = Strict.insertWith
{-# INLINE insertWith' #-}
#endif

-- | /Deprecated./ As of version 0.5, replaced by
-- 'Data.Map.Strict.insertWithKey'.
--
-- /O(log n)/. Same as 'insertWithKey', but the value being inserted to the map is
-- | /O(log n)/. Same as 'insertWithKey', but the value being inserted to the map is
-- evaluated to WHNF beforehand.

{-# DEPRECATED insertWithKey' "As of version 0.5, replaced by 'Data.Map.Strict.insertWithKey'." #-}
insertWithKey' :: Ord k => (k -> a -> a -> a) -> k -> a -> Map k a -> Map k a
-- We do not reuse Data.Map.Strict.insertWithKey, because it is stricter -- it
-- forces evaluation of the given value.
Expand All @@ -106,12 +101,9 @@ insertWithKey' = Strict.insertWithKey
{-# INLINE insertWithKey' #-}
#endif

-- | /Deprecated./ As of version 0.5, replaced by
-- 'Data.Map.Strict.insertLookupWithKey'.
--
-- /O(log n)/. Same as 'insertLookupWithKey', but the value being inserted to
-- | /O(log n)/. Same as 'insertLookupWithKey', but the value being inserted to
-- the map is evaluated to WHNF beforehand.

{-# DEPRECATED insertLookupWithKey' "As of version 0.5, replaced by 'Data.Map.Strict.insertLookupWithKey'." #-}
insertLookupWithKey' :: Ord k => (k -> a -> a -> a) -> k -> a -> Map k a
-> (Maybe a, Map k a)
-- We do not reuse Data.Map.Strict.insertLookupWithKey, because it is stricter -- it
Expand All @@ -123,20 +115,18 @@ insertLookupWithKey' = Strict.insertLookupWithKey
{-# INLINE insertLookupWithKey' #-}
#endif

-- | /Deprecated./ As of version 0.5, replaced by 'foldr'.
--
-- /O(n)/. Fold the values in the map using the given right-associative
-- | /O(n)/. Fold the values in the map using the given right-associative
-- binary operator. This function is an equivalent of 'foldr' and is present
-- for compatibility only.
{-# DEPRECATED fold "As of version 0.5, replaced by 'foldr'." #-}
fold :: (a -> b -> b) -> b -> Map k a -> b
fold = foldr
{-# INLINE fold #-}

-- | /Deprecated./ As of version 0.4, replaced by 'foldrWithKey'.
--
-- /O(n)/. Fold the keys and values in the map using the given right-associative
-- | /O(n)/. Fold the keys and values in the map using the given right-associative
-- binary operator. This function is an equivalent of 'foldrWithKey' and is present
-- for compatibility only.
{-# DEPRECATED foldWithKey "As of version 0.4, replaced by 'foldrWithKey'." #-}
foldWithKey :: (k -> a -> b -> b) -> b -> Map k a -> b
foldWithKey = foldrWithKey
{-# INLINE foldWithKey #-}
2 changes: 2 additions & 0 deletions Data/Map/Base.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3965,6 +3965,7 @@ instance (Show k, Show a) => Show (Map k a) where

-- | /O(n)/. Show the tree that implements the map. The tree is shown
-- in a compressed, hanging format. See 'showTreeWith'.
{-# DEPRECATED showTree "This function is being removed from the public API." #-}
showTree :: (Show k,Show a) => Map k a -> String
showTree m
= showTreeWith showElem True False m
Expand Down Expand Up @@ -4008,6 +4009,7 @@ showTree m
> +--(1,())
-}
{-# DEPRECATED showTreeWith "This function is being removed from the public API." #-}
showTreeWith :: (k -> a -> String) -> Bool -> Bool -> Map k a -> String
showTreeWith showelem hang wide t
| hang = (showsTreeHang showelem wide [] t) ""
Expand Down
10 changes: 10 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@

* Make `drawTree` handle newlines better. (Thanks, recursion-ninja!)

### Deprecations

* All functions in `Data.Map` proper that have been documented as deprecated since
version 0.5 or before now have `DEPRECATED` pragmas and will actually be
removed after another cycle or two.

* Tree printing functions in `Data.Map` intended for library debugging are now
deprecated. They will continue to be available for the foreseeable future in
an internal module.

### Performance changes

* Substantially speed up `splitAt`, `zipWith`, `take`, `drop`,
Expand Down

0 comments on commit eed0db8

Please sign in to comment.