@@ -1,651 +0,0 @@
1−{-# LANGUAGE CPP #-}
2−{-# LANGUAGE ScopedTypeVariables #-}
3−{-# LANGUAGE MultiParamTypeClasses #-}
4−{-# LANGUAGE TypeFamilies #-}
5−{-# LANGUAGE FlexibleInstances #-}
6−{-# LANGUAGE GeneralizedNewtypeDeriving #-}
7−{-# LANGUAGE DeriveTraversable #-}
8−{-# LANGUAGE DeriveDataTypeable #-}
9−{-# LANGUAGE StandaloneDeriving #-}
10−
11−-- | This module provides a 'Data.IntMap' variant which uses the value's
12−-- 'Monoid' instance to accumulate conflicting entries when merging
13−-- 'Map's.
14−--
15−-- While some functions mirroring those of 'Data.IntMap' are provided
16−-- here for convenience, more specialized needs will likely want to use
17−-- either the 'Newtype' or 'Wrapped' instances to manipulate the
18−-- underlying 'Map'.
19−
20−module Data.IntMap.Monoidal.Strict
21− ( MonoidalIntMap(..)
22− -- * Often-needed functions
23− , singleton
24− , size
25− , member
26− , notMember
27− , findWithDefault
28− , assocs
29− , elems
30− , keys
31− , (!)
32− , (\\)
33− , adjust
34− , adjustWithKey
35− , alter
36− , delete
37−-- , deleteAt
38− , deleteFindMax
39− , deleteFindMin
40− , deleteMax
41− , deleteMin
42− , difference
43− , differenceWith
44− , differenceWithKey
45−-- , elemAt
46− , empty
47− , filter
48− , filterWithKey
49−-- , findIndex
50− , findMax
51− , findMin
52− , foldMapWithKey
53− , foldl
54− , foldl'
55− , foldlWithKey
56− , foldlWithKey'
57− , foldr
58− , foldr'
59− , foldrWithKey
60− , foldrWithKey'
61− , fromAscList
62− , fromAscListWith
63− , fromAscListWithKey
64− , fromDistinctAscList
65− , fromDistinctList
66− , fromList
67− , fromListWith
68− , fromListWithKey
69− , fromSet
70− , insert
71− , insertLookupWithKey
72− , insertWith
73− , insertWithKey
74− , intersectionWith
75− , intersectionWithKey
76− , isProperSubmapOf
77− , isProperSubmapOfBy
78− , isSubmapOf
79− , isSubmapOfBy
80− , keysSet
81− , lookup
82− , lookupGE
83− , lookupGT
84−-- , lookupIndex
85− , lookupLE
86− , lookupLT
87− , map
88− , mapAccum
89− , mapAccumRWithKey
90− , mapAccumWithKey
91− , mapEither
92− , mapEitherWithKey
93− , mapKeys
94− , mapKeysMonotonic
95− , mapKeysWith
96− , mapMaybe
97− , mapMaybeWithKey
98− , mapWithKey
99− , maxView
100− , maxViewWithKey
101− , mergeWithKey
102− , minView
103− , minViewWithKey
104− , null
105− , partition
106− , partitionWithKey
107− , split
108− , splitLookup
109− , splitRoot
110− , toAscList
111− , toDescList
112− , toList
113− , traverseWithKey
114− , unionWith
115− , unionWithKey
116− , unionsWith
117− , update
118−-- , updateAt
119− , updateLookupWithKey
120− , updateMax
121− , updateMaxWithKey
122− , updateMin
123− , updateMinWithKey
124− , updateWithKey
125−-- , valid
126− -- , showTree
127− -- , showTreeWith
128− ) where
129−
130−import Prelude hiding (null, lookup, map, foldl, foldr, filter)
131−
132−import Data.Coerce (coerce)
133−import Data.IntSet (IntSet)
134−import Data.Semigroup
135−import Data.Foldable (Foldable)
136−import Data.Traversable (Traversable)
137−import Control.Applicative (Applicative, pure)
138−import Data.Data (Data)
139−import Data.Typeable (Typeable)
140−
141−#if MIN_VERSION_base(4,7,0)
142−import qualified GHC.Exts as IsList
143−#endif
144−
145−import Control.DeepSeq
146−import qualified Data.IntMap.Strict as M
147−import Control.Lens
148−import Control.Newtype
149−import Data.Aeson(FromJSON, ToJSON, FromJSON1, ToJSON1)
150−#if MIN_VERSION_containers(0,5,9)
151−import Data.Functor.Classes
152−#endif
153−import Data.Align
154−#ifdef MIN_VERSION_semialign
155−import Data.Semialign (Unalign)
156−#if MIN_VERSION_semialign(1,1,0)
157−import Data.Zip (Zip)
158−#endif
159−#endif
160−
161−-- | An 'IntMap' with monoidal accumulation
162−newtype MonoidalIntMap a = MonoidalIntMap { getMonoidalIntMap :: M.IntMap a }
163− deriving (Show, Read, Functor, Eq, Ord, NFData,
164− Foldable, Traversable,
165− FromJSON, ToJSON, FromJSON1, ToJSON1,
166− Data, Typeable, Align
167−#if MIN_VERSION_these(0,8,0)
168− , Semialign
169−#endif
170−#ifdef MIN_VERSION_semialign
171− , Unalign
172−#if MIN_VERSION_semialign(1,1,0)
173− , Zip
174−#endif
175−#endif
176− )
177−
178−#if MIN_VERSION_containers(0,5,9)
179−deriving instance Eq1 MonoidalIntMap
180−deriving instance Ord1 MonoidalIntMap
181−deriving instance Show1 MonoidalIntMap
182−#endif
183−
184−type instance Index (MonoidalIntMap a) = Int
185−type instance IxValue (MonoidalIntMap a) = a
186−instance Ixed (MonoidalIntMap a) where
187− ix k f (MonoidalIntMap m) = case M.lookup k m of
188− Just v -> f v <&> \v' -> MonoidalIntMap (M.insert k v' m)
189− Nothing -> pure (MonoidalIntMap m)
190− {-# INLINE ix #-}
191−
192−instance At (MonoidalIntMap a) where
193− at k f (MonoidalIntMap m) = f mv <&> \r -> case r of
194− Nothing -> maybe (MonoidalIntMap m) (const (MonoidalIntMap $ M.delete k m)) mv
195− Just v' -> MonoidalIntMap $ M.insert k v' m
196− where mv = M.lookup k m
197− {-# INLINE at #-}
198−
199−instance Each (MonoidalIntMap a) (MonoidalIntMap b) a b
200−
201−instance FunctorWithIndex Int MonoidalIntMap
202−instance FoldableWithIndex Int MonoidalIntMap
203−instance TraversableWithIndex Int MonoidalIntMap where
204− itraverse f (MonoidalIntMap m) = fmap MonoidalIntMap $ itraverse f m
205− {-# INLINE itraverse #-}
206−
207−instance TraverseMin Int MonoidalIntMap where
208− traverseMin f (MonoidalIntMap m) = fmap MonoidalIntMap $ traverseMin f m
209− {-# INLINE traverseMin #-}
210−instance TraverseMax Int MonoidalIntMap where
211− traverseMax f (MonoidalIntMap m) = fmap MonoidalIntMap $ traverseMax f m
212− {-# INLINE traverseMax #-}
213−
214−instance AsEmpty (MonoidalIntMap a) where
215− _Empty = nearly (MonoidalIntMap M.empty) (M.null . unpack)
216− {-# INLINE _Empty #-}
217−
218−instance Wrapped (MonoidalIntMap a) where
219− type Unwrapped (MonoidalIntMap a) = M.IntMap a
220− _Wrapped' = iso unpack pack
221− {-# INLINE _Wrapped' #-}
222−
223−instance Semigroup a => Semigroup (MonoidalIntMap a) where
224− MonoidalIntMap a <> MonoidalIntMap b = MonoidalIntMap $ M.unionWith (<>) a b
225− {-# INLINE (<>) #-}
226−
227−instance Semigroup a => Monoid (MonoidalIntMap a) where
228− mempty = MonoidalIntMap mempty
229− {-# INLINE mempty #-}
230−#if !(MIN_VERSION_base(4,11,0))
231− mappend (MonoidalIntMap a) (MonoidalIntMap b) = MonoidalIntMap $ M.unionWith (<>) a b
232− {-# INLINE mappend #-}
233−#endif
234−
235−instance Newtype (MonoidalIntMap a) (M.IntMap a) where
236− pack = MonoidalIntMap
237− {-# INLINE pack #-}
238− unpack (MonoidalIntMap a) = a
239− {-# INLINE unpack #-}
240−
241−#if MIN_VERSION_base(4,7,0)
242−instance Semigroup a => IsList.IsList (MonoidalIntMap a) where
243− type Item (MonoidalIntMap a) = (Int, a)
244− fromList = MonoidalIntMap . M.fromListWith (<>)
245− {-# INLINE fromList #-}
246− toList = M.toList . unpack
247− {-# INLINE toList #-}
248−#endif
249−
250−-- | /O(1)/. A map with a single element.
251−singleton :: Int -> a -> MonoidalIntMap a
252−singleton k a = MonoidalIntMap $ M.singleton k a
253−{-# INLINE singleton #-}
254−
255−-- | /O(1)/. The number of elements in the map.
256−size :: MonoidalIntMap a -> Int
257−size = M.size . unpack
258−{-# INLINE size #-}
259−
260−-- | /O(log n)/. Is the key a member of the map? See also 'notMember'.
261−member :: Int -> MonoidalIntMap a -> Bool
262−member k = M.member k . unpack
263−{-# INLINE member #-}
264−
265−-- | /O(log n)/. Is the key not a member of the map? See also 'member'.
266−notMember :: Int -> MonoidalIntMap a -> Bool
267−notMember k = not . M.member k . unpack
268−{-# INLINE notMember #-}
269−
270−-- | /O(log n)/. The expression @('findWithDefault' def k map)@ returns
271−-- the value at key @k@ or returns default value @def@
272−-- when the key is not in the map.
273−findWithDefault :: forall a. a -> Int -> MonoidalIntMap a -> a
274−findWithDefault def k = M.findWithDefault def k . unpack
275−{-# INLINE findWithDefault #-}
276−
277−-- | /O(log n)/. Delete a key and its value from the map. When the key is not
278−-- a member of the map, the original map is returned.
279−delete :: Int -> MonoidalIntMap a -> MonoidalIntMap a
280−delete k = _Wrapping' MonoidalIntMap %~ M.delete k
281−{-# INLINE delete #-}
282−
283−-- | /O(n)/. Return all elements of the map and their keys
284−assocs :: MonoidalIntMap a -> [(Int,a)]
285−assocs = M.assocs . unpack
286−{-# INLINE assocs #-}
287−
288−-- | /O(n)/. Return all elements of the map in the ascending order of their
289−-- keys. Subject to list fusion.
290−elems :: MonoidalIntMap a -> [a]
291−elems = M.elems . unpack
292−{-# INLINE elems #-}
293−
294−-- | /O(n)/. Return all keys of the map in ascending order. Subject to list
295−-- fusion.
296−keys :: MonoidalIntMap a -> [Int]
297−keys = M.keys . unpack
298−{-# INLINE keys #-}
299−
300−(!) :: forall a. MonoidalIntMap a -> Int -> a
301−(!) = coerce ((M.!) :: M.IntMap a -> Int -> a)
302−infixl 9 !
303−
304−(\\) :: forall a b. MonoidalIntMap a -> MonoidalIntMap b -> MonoidalIntMap a
305−(\\) = coerce ((M.\\) :: M.IntMap a -> M.IntMap b -> M.IntMap a)
306−infixl 9 \\ --
307−
308−null :: forall a. MonoidalIntMap a -> Bool
309−null = coerce (M.null :: M.IntMap a -> Bool)
310−{-# INLINE null #-}
311−
312−lookup :: forall a. Int -> MonoidalIntMap a -> Maybe a
313−lookup = coerce (M.lookup :: Int -> M.IntMap a -> Maybe a)
314−{-# INLINE lookup #-}
315−
316−lookupLT :: forall a. Int -> MonoidalIntMap a -> Maybe (Int, a)
317−lookupLT = coerce (M.lookupLT :: Int -> M.IntMap a -> Maybe (Int,a))
318−{-# INLINE lookupLT #-}
319−
320−lookupGT :: forall a. Int -> MonoidalIntMap a -> Maybe (Int, a)
321−lookupGT = coerce (M.lookupGT :: Int -> M.IntMap a -> Maybe (Int,a))
322−{-# INLINE lookupGT #-}
323−
324−lookupLE :: forall a. Int -> MonoidalIntMap a -> Maybe (Int, a)
325−lookupLE = coerce (M.lookupLE :: Int -> M.IntMap a -> Maybe (Int,a))
326−{-# INLINE lookupLE #-}
327−
328−lookupGE :: forall a. Int -> MonoidalIntMap a -> Maybe (Int, a)
329−lookupGE = coerce (M.lookupGE :: Int -> M.IntMap a -> Maybe (Int,a))
330−{-# INLINE lookupGE #-}
331−
332−empty :: forall a. MonoidalIntMap a
333−empty = coerce (M.empty :: M.IntMap a)
334−{-# INLINE empty #-}
335−
336−insert :: forall a. Int -> a -> MonoidalIntMap a -> MonoidalIntMap a
337−insert = coerce (M.insert :: Int -> a -> M.IntMap a -> M.IntMap a)
338−{-# INLINE insert #-}
339−
340−insertWith :: forall a. (a -> a -> a) -> Int -> a -> MonoidalIntMap a -> MonoidalIntMap a
341−insertWith = coerce (M.insertWith :: (a -> a -> a) -> Int -> a -> M.IntMap a -> M.IntMap a)
342−{-# INLINE insertWith #-}
343−
344−insertWithKey :: forall a. (Int -> a -> a -> a) -> Int -> a -> MonoidalIntMap a -> MonoidalIntMap a
345−insertWithKey = coerce (M.insertWithKey :: (Int -> a -> a -> a) -> Int -> a -> M.IntMap a -> M.IntMap a)
346−{-# INLINE insertWithKey #-}
347−
348−insertLookupWithKey :: forall a. (Int -> a -> a -> a) -> Int -> a -> MonoidalIntMap a -> (Maybe a, MonoidalIntMap a)
349−insertLookupWithKey = coerce (M.insertLookupWithKey :: (Int -> a -> a -> a) -> Int -> a -> M.IntMap a -> (Maybe a, M.IntMap a))
350−{-# INLINE insertLookupWithKey #-}
351−
352−adjust :: forall a. (a -> a) -> Int -> MonoidalIntMap a -> MonoidalIntMap a
353−adjust = coerce (M.adjust :: (a -> a) -> Int -> M.IntMap a -> M.IntMap a)
354−{-# INLINE adjust #-}
355−
356−adjustWithKey :: forall a. (Int -> a -> a) -> Int -> MonoidalIntMap a -> MonoidalIntMap a
357−adjustWithKey = coerce (M.adjustWithKey :: (Int -> a -> a) -> Int -> M.IntMap a -> M.IntMap a)
358−{-# INLINE adjustWithKey #-}
359−
360−update :: forall a. (a -> Maybe a) -> Int -> MonoidalIntMap a -> MonoidalIntMap a
361−update = coerce (M.update :: (a -> Maybe a) -> Int -> M.IntMap a -> M.IntMap a)
362−{-# INLINE update #-}
363−
364−updateWithKey :: forall a. (Int -> a -> Maybe a) -> Int -> MonoidalIntMap a -> MonoidalIntMap a
365−updateWithKey = coerce (M.updateWithKey :: (Int -> a -> Maybe a) -> Int -> M.IntMap a -> M.IntMap a)
366−{-# INLINE updateWithKey #-}
367−
368−updateLookupWithKey :: forall a. (Int -> a -> Maybe a) -> Int -> MonoidalIntMap a -> (Maybe a, MonoidalIntMap a)
369−updateLookupWithKey = coerce (M.updateLookupWithKey :: (Int -> a -> Maybe a) -> Int -> M.IntMap a -> (Maybe a, M.IntMap a))
370−{-# INLINE updateLookupWithKey #-}
371−
372−alter :: forall a. (Maybe a -> Maybe a) -> Int -> MonoidalIntMap a -> MonoidalIntMap a
373−alter = coerce (M.alter :: (Maybe a -> Maybe a) -> Int -> M.IntMap a -> M.IntMap a)
374−{-# INLINE alter #-}
375−
376−unionWith :: forall a. (a -> a -> a) -> MonoidalIntMap a -> MonoidalIntMap a -> MonoidalIntMap a
377−unionWith = coerce (M.unionWith :: (a -> a -> a) -> M.IntMap a -> M.IntMap a -> M.IntMap a)
378−{-# INLINE unionWith #-}
379−
380−unionWithKey :: forall a. (Int -> a -> a -> a) -> MonoidalIntMap a -> MonoidalIntMap a -> MonoidalIntMap a
381−unionWithKey = coerce (M.unionWithKey :: (Int -> a -> a -> a) -> M.IntMap a -> M.IntMap a -> M.IntMap a)
382−{-# INLINE unionWithKey #-}
383−
384−unionsWith :: forall a. (a -> a -> a) -> [MonoidalIntMap a] -> MonoidalIntMap a
385−unionsWith = coerce (M.unionsWith :: (a -> a -> a) -> [M.IntMap a] -> M.IntMap a)
386−{-# INLINE unionsWith #-}
387−
388−difference :: forall a b. MonoidalIntMap a -> MonoidalIntMap b -> MonoidalIntMap a
389−difference = (\\)
390−{-# INLINE difference #-}
391−
392−differenceWith :: forall a b. (a -> b -> Maybe a) -> MonoidalIntMap a -> MonoidalIntMap b -> MonoidalIntMap a
393−differenceWith = coerce (M.differenceWith :: (a -> b -> Maybe a) -> M.IntMap a -> M.IntMap b -> M.IntMap a)
394−{-# INLINE differenceWith #-}
395−
396−differenceWithKey :: forall a b. (Int -> a -> b -> Maybe a) -> MonoidalIntMap a -> MonoidalIntMap b -> MonoidalIntMap a
397−differenceWithKey = coerce (M.differenceWithKey :: (Int -> a -> b -> Maybe a) -> M.IntMap a -> M.IntMap b -> M.IntMap a)
398−{-# INLINE differenceWithKey #-}
399−
400−intersectionWith :: forall a b c. (a -> b -> c) -> MonoidalIntMap a -> MonoidalIntMap b -> MonoidalIntMap c
401−intersectionWith = coerce (M.intersectionWith :: (a -> b -> c) -> M.IntMap a -> M.IntMap b -> M.IntMap c)
402−{-# INLINE intersectionWith #-}
403−
404−intersectionWithKey :: forall a b c. (Int -> a -> b -> c) -> MonoidalIntMap a -> MonoidalIntMap b -> MonoidalIntMap c
405−intersectionWithKey = coerce (M.intersectionWithKey :: (Int -> a -> b -> c) -> M.IntMap a -> M.IntMap b -> M.IntMap c)
406−{-# INLINE intersectionWithKey #-}
407−
408−mergeWithKey :: forall a b c. (Int -> a -> b -> Maybe c) -> (MonoidalIntMap a -> MonoidalIntMap c) -> (MonoidalIntMap b -> MonoidalIntMap c) -> MonoidalIntMap a -> MonoidalIntMap b -> MonoidalIntMap c
409−mergeWithKey = coerce (M.mergeWithKey :: (Int -> a -> b -> Maybe c) -> (M.IntMap a -> M.IntMap c) -> (M.IntMap b -> M.IntMap c) -> M.IntMap a -> M.IntMap b -> M.IntMap c)
410−{-# INLINE mergeWithKey #-}
411−
412−map :: (a -> b) -> MonoidalIntMap a -> MonoidalIntMap b
413−map = fmap
414−{-# INLINE map #-}
415−
416−mapWithKey :: forall a b. (Int -> a -> b) -> MonoidalIntMap a -> MonoidalIntMap b
417−mapWithKey = coerce (M.mapWithKey :: (Int -> a -> b) -> M.IntMap a -> M.IntMap b)
418−{-# INLINE mapWithKey #-}
419−
420−traverseWithKey :: Applicative t => (Int -> a -> t b) -> MonoidalIntMap a -> t (MonoidalIntMap b)
421−traverseWithKey = itraverse
422−{-# INLINE traverseWithKey #-}
423−
424−mapAccum :: forall a b c. (a -> b -> (a, c)) -> a -> MonoidalIntMap b -> (a, MonoidalIntMap c)
425−mapAccum = coerce (M.mapAccum :: (a -> b -> (a, c)) -> a -> M.IntMap b -> (a, M.IntMap c))
426−{-# INLINE mapAccum #-}
427−
428−mapAccumWithKey :: forall a b c. (a -> Int -> b -> (a, c)) -> a -> MonoidalIntMap b -> (a, MonoidalIntMap c)
429−mapAccumWithKey = coerce (M.mapAccumWithKey :: (a -> Int -> b -> (a, c)) -> a -> M.IntMap b -> (a, M.IntMap c))
430−{-# INLINE mapAccumWithKey #-}
431−
432−mapAccumRWithKey :: forall a b c. (a -> Int -> b -> (a, c)) -> a -> MonoidalIntMap b -> (a, MonoidalIntMap c)
433−mapAccumRWithKey = coerce (M.mapAccumRWithKey :: (a -> Int -> b -> (a, c)) -> a -> M.IntMap b -> (a, M.IntMap c))
434−{-# INLINE mapAccumRWithKey #-}
435−
436−mapKeys :: forall a. (Int -> Int) -> MonoidalIntMap a -> MonoidalIntMap a
437−mapKeys = coerce (M.mapKeys :: (Int -> Int) -> M.IntMap a -> M.IntMap a)
438−{-# INLINE mapKeys #-}
439−
440−mapKeysWith :: forall a. (a -> a -> a) -> (Int -> Int) -> MonoidalIntMap a -> MonoidalIntMap a
441−mapKeysWith = coerce (M.mapKeysWith :: (a -> a -> a) -> (Int -> Int) -> M.IntMap a -> M.IntMap a)
442−{-# INLINE mapKeysWith #-}
443−
444−mapKeysMonotonic :: forall a. (Int -> Int) -> MonoidalIntMap a -> MonoidalIntMap a
445−mapKeysMonotonic = coerce (M.mapKeysMonotonic :: (Int -> Int) -> M.IntMap a -> M.IntMap a)
446−{-# INLINE mapKeysMonotonic #-}
447−
448−foldr :: forall a b. (a -> b -> b) -> b -> MonoidalIntMap a -> b
449−foldr = coerce (M.foldr :: (a -> b -> b) -> b -> M.IntMap a -> b)
450−{-# INLINE foldr #-}
451−
452−foldl :: forall a b. (a -> b -> a) -> a -> MonoidalIntMap b -> a
453−foldl = coerce (M.foldl :: (a -> b -> a) -> a -> M.IntMap b -> a)
454−{-# INLINE foldl #-}
455−
456−foldrWithKey :: forall a b. (Int -> a -> b -> b) -> b -> MonoidalIntMap a -> b
457−foldrWithKey = coerce (M.foldrWithKey :: (Int -> a -> b -> b) -> b -> M.IntMap a -> b)
458−{-# INLINE foldrWithKey #-}
459−
460−foldlWithKey :: forall a b. (a -> Int -> b -> a) -> a -> MonoidalIntMap b -> a
461−foldlWithKey = coerce (M.foldlWithKey :: (a -> Int -> b -> a) -> a -> M.IntMap b -> a)
462−{-# INLINE foldlWithKey #-}
463−
464−foldMapWithKey :: forall a m. Monoid m => (Int -> a -> m) -> MonoidalIntMap a -> m
465−foldMapWithKey = coerce (M.foldMapWithKey :: Monoid m => (Int -> a -> m) -> M.IntMap a -> m)
466−{-# INLINE foldMapWithKey #-}
467−
468−foldr' :: forall a b. (a -> b -> b) -> b -> MonoidalIntMap a -> b
469−foldr' = coerce (M.foldr' :: (a -> b -> b) -> b -> M.IntMap a -> b)
470−{-# INLINE foldr' #-}
471−
472−foldl' :: forall a b. (a -> b -> a) -> a -> MonoidalIntMap b -> a
473−foldl' = coerce (M.foldl' :: (a -> b -> a) -> a -> M.IntMap b -> a)
474−{-# INLINE foldl' #-}
475−
476−foldrWithKey' :: forall a b. (Int -> a -> b -> b) -> b -> MonoidalIntMap a -> b
477−foldrWithKey' = coerce (M.foldrWithKey' :: (Int -> a -> b -> b) -> b -> M.IntMap a -> b)
478−{-# INLINE foldrWithKey' #-}
479−
480−foldlWithKey' :: forall a b. (a -> Int -> b -> a) -> a -> MonoidalIntMap b -> a
481−foldlWithKey' = coerce (M.foldlWithKey' :: (a -> Int -> b -> a) -> a -> M.IntMap b -> a)
482−{-# INLINE foldlWithKey' #-}
483−
484−keysSet :: forall a. MonoidalIntMap a -> IntSet
485−keysSet = coerce (M.keysSet :: M.IntMap a -> IntSet)
486−{-# INLINE keysSet #-}
487−
488−fromSet :: forall a. (Int -> a) -> IntSet -> MonoidalIntMap a
489−fromSet = coerce (M.fromSet :: (Int -> a) -> IntSet -> M.IntMap a)
490−{-# INLINE fromSet #-}
491−
492−toList :: forall a. MonoidalIntMap a -> [(Int, a)]
493−toList = coerce (M.toList :: M.IntMap a -> [(Int, a)])
494−{-# INLINE toList #-}
495−
496−fromList :: forall a. [(Int, a)] -> MonoidalIntMap a
497−fromList = coerce (M.fromList :: [(Int, a)] -> M.IntMap a)
498−{-# INLINE fromList #-}
499−
500−fromListWith :: forall a. (a -> a -> a) -> [(Int, a)] -> MonoidalIntMap a
501−fromListWith = coerce (M.fromListWith :: (a -> a -> a) -> [(Int, a)] -> M.IntMap a)
502−{-# INLINE fromListWith #-}
503−
504−fromListWithKey :: forall a. (Int -> a -> a -> a) -> [(Int, a)] -> MonoidalIntMap a
505−fromListWithKey = coerce (M.fromListWithKey :: (Int -> a -> a -> a) -> [(Int, a)] -> M.IntMap a)
506−{-# INLINE fromListWithKey #-}
507−
508−toAscList :: forall a. MonoidalIntMap a -> [(Int, a)]
509−toAscList = coerce (M.toAscList :: M.IntMap a -> [(Int, a)])
510−{-# INLINE toAscList #-}
511−
512−toDescList :: forall a. MonoidalIntMap a -> [(Int, a)]
513−toDescList = coerce (M.toDescList :: M.IntMap a -> [(Int, a)])
514−{-# INLINE toDescList #-}
515−
516−fromAscList :: forall a. [(Int, a)] -> MonoidalIntMap a
517−fromAscList = coerce (M.fromAscList :: [(Int, a)] -> M.IntMap a)
518−{-# INLINE fromAscList #-}
519−
520−fromAscListWith :: forall a. (a -> a -> a) -> [(Int, a)] -> MonoidalIntMap a
521−fromAscListWith = coerce (M.fromAscListWith :: (a -> a -> a) -> [(Int, a)] -> M.IntMap a)
522−{-# INLINE fromAscListWith #-}
523−
524−fromAscListWithKey :: forall a. (Int -> a -> a -> a) -> [(Int, a)] -> MonoidalIntMap a
525−fromAscListWithKey = coerce (M.fromAscListWithKey :: (Int -> a -> a -> a) -> [(Int, a)] -> M.IntMap a)
526−{-# INLINE fromAscListWithKey #-}
527−
528−fromDistinctAscList :: forall a. [(Int, a)] -> MonoidalIntMap a
529−fromDistinctAscList = coerce (M.fromDistinctAscList :: [(Int, a)] -> M.IntMap a)
530−{-# INLINE fromDistinctAscList #-}
531−
532−fromDistinctList :: forall a. [(Int, a)] -> MonoidalIntMap a
533−fromDistinctList = coerce (M.fromList :: [(Int, a)] -> M.IntMap a)
534−{-# INLINE fromDistinctList #-}
535−
536−filter :: forall a. (a -> Bool) -> MonoidalIntMap a -> MonoidalIntMap a
537−filter = coerce (M.filter :: (a -> Bool) -> M.IntMap a -> M.IntMap a)
538−{-# INLINE filter #-}
539−
540−filterWithKey :: forall a. (Int -> a -> Bool) -> MonoidalIntMap a -> MonoidalIntMap a
541−filterWithKey = coerce (M.filterWithKey :: (Int -> a -> Bool) -> M.IntMap a -> M.IntMap a)
542−{-# INLINE filterWithKey #-}
543−
544−partition :: forall a. (a -> Bool) -> MonoidalIntMap a -> (MonoidalIntMap a, MonoidalIntMap a)
545−partition = coerce (M.partition :: (a -> Bool) -> M.IntMap a -> (M.IntMap a, M.IntMap a))
546−{-# INLINE partition #-}
547−
548−partitionWithKey :: forall a. (Int -> a -> Bool) -> MonoidalIntMap a -> (MonoidalIntMap a, MonoidalIntMap a)
549−partitionWithKey = coerce (M.partitionWithKey :: (Int -> a -> Bool) -> M.IntMap a -> (M.IntMap a, M.IntMap a))
550−{-# INLINE partitionWithKey #-}
551−
552−mapMaybe :: forall a b. (a -> Maybe b) -> MonoidalIntMap a -> MonoidalIntMap b
553−mapMaybe = coerce (M.mapMaybe :: (a -> Maybe b) -> M.IntMap a -> M.IntMap b)
554−{-# INLINE mapMaybe #-}
555−
556−mapMaybeWithKey :: forall a b. (Int -> a -> Maybe b) -> MonoidalIntMap a -> MonoidalIntMap b
557−mapMaybeWithKey = coerce (M.mapMaybeWithKey :: (Int -> a -> Maybe b) -> M.IntMap a -> M.IntMap b)
558−{-# INLINE mapMaybeWithKey #-}
559−
560−mapEither :: forall a b c. (a -> Either b c) -> MonoidalIntMap a -> (MonoidalIntMap b, MonoidalIntMap c)
561−mapEither = coerce (M.mapEither :: (a -> Either b c) -> M.IntMap a -> (M.IntMap b, M.IntMap c))
562−{-# INLINE mapEither #-}
563−
564−mapEitherWithKey :: forall a b c. (Int -> a -> Either b c) -> MonoidalIntMap a -> (MonoidalIntMap b, MonoidalIntMap c)
565−mapEitherWithKey = coerce (M.mapEitherWithKey :: (Int -> a -> Either b c) -> M.IntMap a -> (M.IntMap b, M.IntMap c))
566−{-# INLINE mapEitherWithKey #-}
567−
568−split :: forall a. Int -> MonoidalIntMap a -> (MonoidalIntMap a, MonoidalIntMap a)
569−split = coerce (M.split :: Int -> M.IntMap a -> (M.IntMap a, M.IntMap a))
570−{-# INLINE split #-}
571−
572−splitLookup :: forall a. Int -> MonoidalIntMap a -> (MonoidalIntMap a, Maybe a, MonoidalIntMap a)
573−splitLookup = coerce (M.splitLookup :: Int -> M.IntMap a -> (M.IntMap a, Maybe a, M.IntMap a))
574−{-# INLINE splitLookup #-}
575−
576−splitRoot :: forall a. MonoidalIntMap a -> [MonoidalIntMap a]
577−splitRoot = coerce (M.splitRoot :: M.IntMap a -> [M.IntMap a])
578−{-# INLINE splitRoot #-}
579−
580−isSubmapOf :: forall a. Eq a => MonoidalIntMap a -> MonoidalIntMap a -> Bool
581−isSubmapOf = coerce (M.isSubmapOf :: M.IntMap a -> M.IntMap a -> Bool)
582−{-# INLINE isSubmapOf #-}
583−
584−isSubmapOfBy :: forall a b. (a -> b -> Bool) -> MonoidalIntMap a -> MonoidalIntMap b -> Bool
585−isSubmapOfBy = coerce (M.isSubmapOfBy :: (a -> b -> Bool) -> M.IntMap a -> M.IntMap b -> Bool)
586−{-# INLINE isSubmapOfBy #-}
587−
588−isProperSubmapOf :: forall a. Eq a => MonoidalIntMap a -> MonoidalIntMap a -> Bool
589−isProperSubmapOf = coerce (M.isProperSubmapOf :: M.IntMap a -> M.IntMap a -> Bool)
590−{-# INLINE isProperSubmapOf #-}
591−
592−isProperSubmapOfBy :: forall a b. (a -> b -> Bool) -> MonoidalIntMap a -> MonoidalIntMap b -> Bool
593−isProperSubmapOfBy = coerce (M.isProperSubmapOfBy :: (a -> b -> Bool) -> M.IntMap a -> M.IntMap b -> Bool)
594−{-# INLINE isProperSubmapOfBy #-}
595−
596−findMin :: forall a. MonoidalIntMap a -> (Int, a)
597−findMin = coerce (M.findMin :: M.IntMap a -> (Int, a))
598−{-# INLINE findMin #-}
599−
600−findMax :: forall a. MonoidalIntMap a -> (Int, a)
601−findMax = coerce (M.findMax :: M.IntMap a -> (Int, a))
602−{-# INLINE findMax #-}
603−
604−deleteMin :: forall a. MonoidalIntMap a -> MonoidalIntMap a
605−deleteMin = coerce (M.deleteMin :: M.IntMap a -> M.IntMap a)
606−{-# INLINE deleteMin #-}
607−
608−deleteMax :: forall a. MonoidalIntMap a -> MonoidalIntMap a
609−deleteMax = coerce (M.deleteMax :: M.IntMap a -> M.IntMap a)
610−{-# INLINE deleteMax #-}
611−
612−deleteFindMin :: forall a. MonoidalIntMap a -> ((Int, a), MonoidalIntMap a)
613−deleteFindMin = coerce (M.deleteFindMin :: M.IntMap a -> ((Int, a), M.IntMap a))
614−{-# INLINE deleteFindMin #-}
615−
616−deleteFindMax :: forall a. MonoidalIntMap a -> ((Int, a), MonoidalIntMap a)
617−deleteFindMax = coerce (M.deleteFindMax :: M.IntMap a -> ((Int, a), M.IntMap a))
618−{-# INLINE deleteFindMax #-}
619−
620−updateMin :: forall a. (a -> Maybe a) -> MonoidalIntMap a -> MonoidalIntMap a
621−updateMin = coerce (M.updateMin :: (a -> Maybe a) -> M.IntMap a -> M.IntMap a)
622−{-# INLINE updateMin #-}
623−
624−updateMax :: forall a. (a -> Maybe a) -> MonoidalIntMap a -> MonoidalIntMap a
625−updateMax = coerce (M.updateMax :: (a -> Maybe a) -> M.IntMap a -> M.IntMap a)
626−{-# INLINE updateMax #-}
627−
628−updateMinWithKey :: forall a. (Int -> a -> Maybe a) -> MonoidalIntMap a -> MonoidalIntMap a
629−updateMinWithKey = coerce (M.updateMinWithKey :: (Int -> a -> Maybe a) -> M.IntMap a -> M.IntMap a)
630−{-# INLINE updateMinWithKey #-}
631−
632−updateMaxWithKey :: forall a. (Int -> a -> Maybe a) -> MonoidalIntMap a -> MonoidalIntMap a
633−updateMaxWithKey = coerce (M.updateMaxWithKey :: (Int -> a -> Maybe a) -> M.IntMap a -> M.IntMap a)
634−{-# INLINE updateMaxWithKey #-}
635−
636−minView :: forall a. MonoidalIntMap a -> Maybe (a, MonoidalIntMap a)
637−minView = coerce (M.minView :: M.IntMap a -> Maybe (a, M.IntMap a))
638−{-# INLINE minView #-}
639−
640−maxView :: forall a. MonoidalIntMap a -> Maybe (a, MonoidalIntMap a)
641−maxView = coerce (M.maxView :: M.IntMap a -> Maybe (a, M.IntMap a))
642−{-# INLINE maxView #-}
643−
644−minViewWithKey :: forall a. MonoidalIntMap a -> Maybe ((Int, a), MonoidalIntMap a)
645−minViewWithKey = coerce (M.minViewWithKey :: M.IntMap a -> Maybe ((Int, a), M.IntMap a))
646−{-# INLINE minViewWithKey #-}
647−
648−maxViewWithKey :: forall a. MonoidalIntMap a -> Maybe ((Int, a), MonoidalIntMap a)
649−maxViewWithKey = coerce (M.maxViewWithKey :: M.IntMap a -> Maybe ((Int, a), M.IntMap a))
650−{-# INLINE maxViewWithKey #-}
651−