Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove strict compose versions #745

Merged
merged 1 commit into from
Sep 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions containers/src/Data/IntMap/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,10 @@ disjoint t1@(Bin p1 m1 l1 r1) t2@(Bin p2 m2 l2 r2)
-- ('compose' bc ab '!?') = (bc '!?') <=< (ab '!?')
-- @
--
-- __Note:__ Prior to UNRELEASED, "Data.IntMap.Strict" exposed a version of
-- 'compose' that forced the values of the output 'IntMap'. This version does
-- not force these values.
--
-- @since 0.6.3.1
compose :: IntMap c -> IntMap Int -> IntMap c
compose bc !ab
Expand Down
22 changes: 1 addition & 21 deletions containers/src/Data/IntMap/Strict/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ import Data.IntMap.Internal
, foldrWithKey'
, keysSet
, mergeWithKey'
, compose
, delete
, deleteMin
, deleteMax
Expand Down Expand Up @@ -718,27 +719,6 @@ intersectionWithKey :: (Key -> a -> b -> c) -> IntMap a -> IntMap b -> IntMap c
intersectionWithKey f m1 m2
= mergeWithKey' bin (\(Tip k1 x1) (Tip _k2 x2) -> Tip k1 $! f k1 x1 x2) (const Nil) (const Nil) m1 m2

{--------------------------------------------------------------------
Compose
--------------------------------------------------------------------}
-- | Relate the keys of one map to the values of
-- the other, by using the values of the former as keys for lookups
-- in the latter.
--
-- Complexity: \( O(n * \min(m,W)) \), where \(m\) is the size of the first argument
--
-- > compose (fromList [('a', "A"), ('b', "B")]) (fromList [(1,'a'),(2,'b'),(3,'z')]) = fromList [(1,"A"),(2,"B")]
--
-- @
-- ('compose' bc ab '!?') = (bc '!?') <=< (ab '!?')
-- @
--
-- @since 0.6.3.1
compose :: IntMap c -> IntMap Int -> IntMap c
compose bc !ab
| null bc = empty
| otherwise = mapMaybe (bc !?) ab

{--------------------------------------------------------------------
MergeWithKey
--------------------------------------------------------------------}
Expand Down
4 changes: 4 additions & 0 deletions containers/src/Data/Map/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2106,6 +2106,10 @@ disjoint (Bin _ k _ l r) t
-- ('compose' bc ab '!?') = (bc '!?') <=< (ab '!?')
-- @
--
-- __Note:__ Prior to UNRELEASED, "Data.Map.Strict" exposed a version of
-- 'compose' that forced the values of the output 'Map'. This version does not
-- force these values.
--
-- @since 0.6.3.1
compose :: Ord b => Map b c -> Map a b -> Map a c
compose bc !ab
Expand Down
22 changes: 1 addition & 21 deletions containers/src/Data/Map/Strict/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ import Data.Map.Internal
, balance
, balanceL
, balanceR
, compose
, elemAt
, elems
, empty
Expand Down Expand Up @@ -1205,27 +1206,6 @@ forceMaybe Nothing = Nothing
forceMaybe m@(Just !_) = m
{-# INLINE forceMaybe #-}

{--------------------------------------------------------------------
Compose
--------------------------------------------------------------------}
-- | Relate the keys of one map to the values of
-- the other, by using the values of the former as keys for lookups
-- in the latter.
--
-- Complexity: \( O (n * \log(m)) \), where \(m\) is the size of the first argument
--
-- > compose (fromList [('a', "A"), ('b', "B")]) (fromList [(1,'a'),(2,'b'),(3,'z')]) = fromList [(1,"A"),(2,"B")]
--
-- @
-- ('compose' bc ab '!?') = (bc '!?') <=< (ab '!?')
-- @
--
-- @since 0.6.3.1
compose :: Ord b => Map b c -> Map a b -> Map a c
compose bc !ab
| null bc = empty
| otherwise = mapMaybe (bc !?) ab

{--------------------------------------------------------------------
MergeWithKey
--------------------------------------------------------------------}
Expand Down