summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Smeding <tom@tomsmeding.com>2024-09-30 09:41:05 +0200
committerTom Smeding <tom@tomsmeding.com>2024-09-30 09:41:05 +0200
commit36719b2bad780e7821aa1dd6698b468fb460e2b6 (patch)
tree78e2d7ef070324a6b4d2ea0af9f1d985a14009e7
parent6c7bddea920e0058e17f973fff1cc3e17f01c088 (diff)
partitionWithKeyHEADmaster
-rw-r--r--src/Data/Dependent/EnumMap/Strict.hs2
-rw-r--r--src/Data/Dependent/EnumMap/Strict/Internal.hs4
2 files changed, 4 insertions, 2 deletions
diff --git a/src/Data/Dependent/EnumMap/Strict.hs b/src/Data/Dependent/EnumMap/Strict.hs
index c3141be..fd650b2 100644
--- a/src/Data/Dependent/EnumMap/Strict.hs
+++ b/src/Data/Dependent/EnumMap/Strict.hs
@@ -145,7 +145,7 @@ module Data.Dependent.EnumMap.Strict (
-- restrictKeys
-- withoutKeys
partition,
- -- partitionWithKey
+ partitionWithKey,
-- takeWhileAntitone
-- dropWhileAntitone
diff --git a/src/Data/Dependent/EnumMap/Strict/Internal.hs b/src/Data/Dependent/EnumMap/Strict/Internal.hs
index 7e54a64..0d944ba 100644
--- a/src/Data/Dependent/EnumMap/Strict/Internal.hs
+++ b/src/Data/Dependent/EnumMap/Strict/Internal.hs
@@ -247,7 +247,9 @@ partition :: (forall a. v a -> Bool) -> DEnumMap k v -> (DEnumMap k v, DEnumMap
partition f (DEnumMap m) =
bimap DEnumMap DEnumMap (IM.partition (\(KV _ v) -> f v) m)
--- partitionWithKey
+partitionWithKey :: Enum1 k => (forall a. k a -> v a -> Bool) -> DEnumMap k v -> (DEnumMap k v, DEnumMap k v)
+partitionWithKey f (DEnumMap m) =
+ bimap DEnumMap DEnumMap (IM.partitionWithKey (\i (KV inf v) -> case toEnum1 i inf of Some k -> f k (coe1 v)) m)
-- takeWhileAntitone
-- dropWhileAntitone