Skip to content

Commit 747201b

Browse files
Support containers-0.8 in traverseMapWithKey.
1 parent de9ba5c commit 747201b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/Data/IntMap/NonEmpty/Internal.hs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -716,11 +716,19 @@ insertMaxMap = M.insert
716716
-- | /O(n)/. A fixed version of 'Data.IntMap.traverseWithKey' that
717717
-- traverses items in ascending order of keys.
718718
traverseMapWithKey :: Applicative t => (Key -> a -> t b) -> IntMap a -> t (IntMap b)
719+
#if MIN_VERSION_containers(0,8,0)
720+
traverseMapWithKey f = go
721+
where
722+
go Nil = pure Nil
723+
go (Tip k v) = Tip k <$> f k v
724+
go (Bin p l r) = liftA2 (flip (Bin p)) (go r) (go l)
725+
#else
719726
traverseMapWithKey f = go
720727
where
721728
go Nil = pure Nil
722729
go (Tip k v) = Tip k <$> f k v
723730
go (Bin p m l r) = liftA2 (flip (Bin p m)) (go r) (go l)
731+
#endif
724732
{-# INLINE traverseMapWithKey #-}
725733

726734
-- ---------------------------------------------

0 commit comments

Comments
 (0)