diff --git a/containers/src/Data/IntMap/Internal.hs b/containers/src/Data/IntMap/Internal.hs index d20b093741b6f409108935d73de8c06e97ea91df..5caebcb0f03fe3153f52796fdbd8e8690d00614d 100644 --- a/containers/src/Data/IntMap/Internal.hs +++ b/containers/src/Data/IntMap/Internal.hs @@ -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 diff --git a/containers/src/Data/IntMap/Strict/Internal.hs b/containers/src/Data/IntMap/Strict/Internal.hs index a4f2444cd51f52441b05112c160b2740a1f63839..7c639ef96027262ffbf5ab6745f983b29b2a4744 100644 --- a/containers/src/Data/IntMap/Strict/Internal.hs +++ b/containers/src/Data/IntMap/Strict/Internal.hs @@ -293,6 +293,7 @@ import Data.IntMap.Internal , foldrWithKey' , keysSet , mergeWithKey' + , compose , delete , deleteMin , deleteMax @@ -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 --------------------------------------------------------------------} diff --git a/containers/src/Data/Map/Internal.hs b/containers/src/Data/Map/Internal.hs index d3cdfa0bd1731e9764fd6821f09488bdc6384550..a12d3c4ab90d5b37eda2a835876a98899e1d4780 100644 --- a/containers/src/Data/Map/Internal.hs +++ b/containers/src/Data/Map/Internal.hs @@ -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 diff --git a/containers/src/Data/Map/Strict/Internal.hs b/containers/src/Data/Map/Strict/Internal.hs index 8134fe667d3f6cf67bb4512ce3b5cb480c205142..1abbec58509a9988ec64d7abc7ccff3fe58bed64 100644 --- a/containers/src/Data/Map/Strict/Internal.hs +++ b/containers/src/Data/Map/Strict/Internal.hs @@ -335,6 +335,7 @@ import Data.Map.Internal , balance , balanceL , balanceR + , compose , elemAt , elems , empty @@ -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 --------------------------------------------------------------------}