From 36719b2bad780e7821aa1dd6698b468fb460e2b6 Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Mon, 30 Sep 2024 09:41:05 +0200 Subject: partitionWithKey --- src/Data/Dependent/EnumMap/Strict/Internal.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/Data/Dependent/EnumMap/Strict/Internal.hs') 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 -- cgit v1.2.3-70-g09d2