From 4d2c27328c76b6e3413bed4d1e09483fb4890c37 Mon Sep 17 00:00:00 2001 From: Simon Jakobi Date: Sun, 19 Jul 2020 16:25:42 +0200 Subject: [PATCH] Expose IntMap.traverseMaybeWithKey Closes #402. --- containers/src/Data/IntMap/Internal.hs | 2 ++ containers/src/Data/IntMap/Lazy.hs | 1 + containers/src/Data/IntMap/Strict.hs | 1 + containers/src/Data/IntMap/Strict/Internal.hs | 2 ++ 4 files changed, 6 insertions(+) diff --git a/containers/src/Data/IntMap/Internal.hs b/containers/src/Data/IntMap/Internal.hs index 3346e7c59..d20b09374 100644 --- a/containers/src/Data/IntMap/Internal.hs +++ b/containers/src/Data/IntMap/Internal.hs @@ -1891,6 +1891,8 @@ traverseMaybeMissing f = WhenMissing -- | /O(n)/. Traverse keys\/values and collect the 'Just' results. +-- +-- @since UNRELEASED traverseMaybeWithKey :: Applicative f => (Key -> a -> f (Maybe b)) -> IntMap a -> f (IntMap b) traverseMaybeWithKey f = go diff --git a/containers/src/Data/IntMap/Lazy.hs b/containers/src/Data/IntMap/Lazy.hs index 3f38e3c29..989e352db 100644 --- a/containers/src/Data/IntMap/Lazy.hs +++ b/containers/src/Data/IntMap/Lazy.hs @@ -157,6 +157,7 @@ module Data.IntMap.Lazy ( , IM.map , mapWithKey , traverseWithKey + , traverseMaybeWithKey , mapAccum , mapAccumWithKey , mapAccumRWithKey diff --git a/containers/src/Data/IntMap/Strict.hs b/containers/src/Data/IntMap/Strict.hs index 36bbad1e2..672a5533f 100644 --- a/containers/src/Data/IntMap/Strict.hs +++ b/containers/src/Data/IntMap/Strict.hs @@ -176,6 +176,7 @@ module Data.IntMap.Strict ( , map , mapWithKey , traverseWithKey + , traverseMaybeWithKey , mapAccum , mapAccumWithKey , mapAccumRWithKey diff --git a/containers/src/Data/IntMap/Strict/Internal.hs b/containers/src/Data/IntMap/Strict/Internal.hs index b3bb68886..a4f2444cd 100644 --- a/containers/src/Data/IntMap/Strict/Internal.hs +++ b/containers/src/Data/IntMap/Strict/Internal.hs @@ -923,6 +923,8 @@ traverseWithKey f = go {-# INLINE traverseWithKey #-} -- | /O(n)/. Traverse keys\/values and collect the 'Just' results. +-- +-- @since UNRELEASED traverseMaybeWithKey :: Applicative f => (Key -> a -> f (Maybe b)) -> IntMap a -> f (IntMap b) traverseMaybeWithKey f = go