@@ -1,10 +1,12 @@
1{-# LANGUAGE CPP #-}
1{-# LANGUAGE CPP #-}
2+{-# LANGUAGE ScopedTypeVariables #-}
2{-# LANGUAGE MultiParamTypeClasses #-}
3{-# LANGUAGE MultiParamTypeClasses #-}
3{-# LANGUAGE TypeFamilies #-}
4{-# LANGUAGE TypeFamilies #-}
4{-# LANGUAGE FlexibleInstances #-}
5{-# LANGUAGE FlexibleInstances #-}
5{-# LANGUAGE GeneralizedNewtypeDeriving #-}
6{-# LANGUAGE GeneralizedNewtypeDeriving #-}
6{-# LANGUAGE DeriveTraversable #-}
7{-# LANGUAGE DeriveTraversable #-}
7{-# LANGUAGE DeriveDataTypeable #-}
8{-# LANGUAGE DeriveDataTypeable #-}
9+{-# LANGUAGE StandaloneDeriving #-}
9-- | This module provides a 'Data.Map' variant which uses the value's
11-- | This module provides a 'Data.Map' variant which uses the value's
10-- 'Monoid' instance to accumulate conflicting entries when merging
12-- 'Monoid' instance to accumulate conflicting entries when merging
@@ -26,8 +28,108 @@ module Data.Map.Monoidal
64+ , fromDistinctAscList
70+ , insertLookupWithKey
74+ , intersectionWithKey
118+ , updateLookupWithKey
129+import Prelude hiding (null, lookup, map, foldl, foldr, filter)
131+import Data.Coerce (coerce)
132+import Data.Set (Set)
31import Data.Semigroup
133import Data.Semigroup
32import Data.Foldable (Foldable)
134import Data.Foldable (Foldable)
33import Data.Traversable (Traversable)
135import Data.Traversable (Traversable)
@@ -36,20 +138,31 @@ import Data.Data (Data)
36import Data.Typeable (Typeable)
138import Data.Typeable (Typeable)
38#if MIN_VERSION_base(4,7,0)
140#if MIN_VERSION_base(4,7,0)
39−import GHC.Exts (IsList(..))
141+import qualified GHC.Exts as IsList
42import Control.DeepSeq
144import Control.DeepSeq
43import qualified Data.Map as M
145import qualified Data.Map as M
44import Control.Lens
146import Control.Lens
45import Control.Newtype
147import Control.Newtype
148+import Data.Aeson(FromJSON, ToJSON, FromJSON1, ToJSON1)
149+#if MIN_VERSION_containers(0,5,9)
150+import Data.Functor.Classes
47-- | A 'Map' with monoidal accumulation
153-- | A 'Map' with monoidal accumulation
48newtype MonoidalMap k a = MonoidalMap { getMonoidalMap :: M.Map k a }
154newtype MonoidalMap k a = MonoidalMap { getMonoidalMap :: M.Map k a }
49 deriving (Show, Read, Functor, Eq, Ord, NFData,
155 deriving (Show, Read, Functor, Eq, Ord, NFData,
50 Foldable, Traversable,
156 Foldable, Traversable,
157+ FromJSON, ToJSON, FromJSON1, ToJSON1,
51 Data, Typeable)
158 Data, Typeable)
160+#if MIN_VERSION_containers(0,5,9)
161+deriving instance (Ord k) => Eq1 (MonoidalMap k)
162+deriving instance (Ord k) => Ord1 (MonoidalMap k)
163+deriving instance (Show k) => Show1 (MonoidalMap k)
53type instance Index (MonoidalMap k a) = k
166type instance Index (MonoidalMap k a) = k
54type instance IxValue (MonoidalMap k a) = a
167type instance IxValue (MonoidalMap k a) = a
55instance Ord k => Ixed (MonoidalMap k a) where
168instance Ord k => Ixed (MonoidalMap k a) where
@@ -67,9 +180,9 @@ instance Ord k => At (MonoidalMap k a) where
68instance Each (MonoidalMap k a) (MonoidalMap k b) a b
181instance Each (MonoidalMap k a) (MonoidalMap k b) a b
70−instance Ord k => FunctorWithIndex k (MonoidalMap k)
183+instance FunctorWithIndex k (MonoidalMap k)
71−instance Ord k => FoldableWithIndex k (MonoidalMap k)
184+instance FoldableWithIndex k (MonoidalMap k)
72−instance Ord k => TraversableWithIndex k (MonoidalMap k) where
185+instance TraversableWithIndex k (MonoidalMap k) where
73 itraverse f (MonoidalMap m) = fmap MonoidalMap $ itraverse f m
186 itraverse f (MonoidalMap m) = fmap MonoidalMap $ itraverse f m
74 {-# INLINE itraverse #-}
187 {-# INLINE itraverse #-}
@@ -108,7 +221,7 @@ instance Newtype (MonoidalMap k a) (M.Map k a) where
108 {-# INLINE unpack #-}
221 {-# INLINE unpack #-}
110#if MIN_VERSION_base(4,7,0)
223#if MIN_VERSION_base(4,7,0)
111−instance (Ord k, Semigroup a) => IsList (MonoidalMap k a) where
224+instance (Ord k, Semigroup a) => IsList.IsList (MonoidalMap k a) where
112 type Item (MonoidalMap k a) = (k, a)
225 type Item (MonoidalMap k a) = (k, a)
113 fromList = MonoidalMap . M.fromListWith (<>)
226 fromList = MonoidalMap . M.fromListWith (<>)
114 {-# INLINE fromList #-}
227 {-# INLINE fromList #-}
@@ -117,7 +230,7 @@ instance (Ord k, Semigroup a) => IsList (MonoidalMap k a) where
119-- | /O(1)/. A map with a single element.
232-- | /O(1)/. A map with a single element.
120−singleton :: Ord k => k -> a -> MonoidalMap k a
233+singleton :: k -> a -> MonoidalMap k a
121singleton k a = MonoidalMap $ M.singleton k a
234singleton k a = MonoidalMap $ M.singleton k a
122{-# INLINE singleton #-}
235{-# INLINE singleton #-}
@@ -165,3 +278,387 @@ elems = M.elems . unpack
165keys :: MonoidalMap k a -> [k]
278keys :: MonoidalMap k a -> [k]
166keys = M.keys . unpack
279keys = M.keys . unpack
167{-# INLINE keys #-}
280{-# INLINE keys #-}
284+(!) :: forall k a. Ord k => MonoidalMap k a -> k -> a
285+(!) = coerce ((M.!) :: M.Map k a -> k -> a)
288+(\\) :: forall k a b. Ord k => MonoidalMap k a -> MonoidalMap k b -> MonoidalMap k a
289+(\\) = coerce ((M.\\) :: M.Map k a -> M.Map k b -> M.Map k a)
292+null :: forall k a. MonoidalMap k a -> Bool
293+null = coerce (M.null :: M.Map k a -> Bool)
296+lookup :: forall k a. Ord k => k -> MonoidalMap k a -> Maybe a
297+lookup = coerce (M.lookup :: k -> M.Map k a -> Maybe a)
298+{-# INLINE lookup #-}
300+lookupLT :: forall k a. Ord k => k -> MonoidalMap k a -> Maybe (k, a)
301+lookupLT = coerce (M.lookupLT :: k -> M.Map k a -> Maybe (k,a))
302+{-# INLINE lookupLT #-}
304+lookupGT :: forall k a. Ord k => k -> MonoidalMap k a -> Maybe (k, a)
305+lookupGT = coerce (M.lookupGT :: k -> M.Map k a -> Maybe (k,a))
306+{-# INLINE lookupGT #-}
308+lookupLE :: forall k a. Ord k => k -> MonoidalMap k a -> Maybe (k, a)
309+lookupLE = coerce (M.lookupLE :: k -> M.Map k a -> Maybe (k,a))
310+{-# INLINE lookupLE #-}
312+lookupGE :: forall k a. Ord k => k -> MonoidalMap k a -> Maybe (k, a)
313+lookupGE = coerce (M.lookupGE :: k -> M.Map k a -> Maybe (k,a))
314+{-# INLINE lookupGE #-}
316+empty :: forall k a. MonoidalMap k a
317+empty = coerce (M.empty :: M.Map k a)
320+insert :: forall k a. Ord k => k -> a -> MonoidalMap k a -> MonoidalMap k a
321+insert = coerce (M.insert :: k -> a -> M.Map k a -> M.Map k a)
322+{-# INLINE insert #-}
324+insertWith :: forall k a. Ord k => (a -> a -> a) -> k -> a -> MonoidalMap k a -> MonoidalMap k a
325+insertWith = coerce (M.insertWith :: (a -> a -> a) -> k -> a -> M.Map k a -> M.Map k a)
326+{-# INLINE insertWith #-}
328+insertWithKey :: forall k a. Ord k => (k -> a -> a -> a) -> k -> a -> MonoidalMap k a -> MonoidalMap k a
329+insertWithKey = coerce (M.insertWithKey :: (k -> a -> a -> a) -> k -> a -> M.Map k a -> M.Map k a)
330+{-# INLINE insertWithKey #-}
332+insertLookupWithKey :: forall k a. Ord k => (k -> a -> a -> a) -> k -> a -> MonoidalMap k a -> (Maybe a, MonoidalMap k a)
333+insertLookupWithKey = coerce (M.insertLookupWithKey :: (k -> a -> a -> a) -> k -> a -> M.Map k a -> (Maybe a, M.Map k a))
334+{-# INLINE insertLookupWithKey #-}
336+adjust :: forall k a. Ord k => (a -> a) -> k -> MonoidalMap k a -> MonoidalMap k a
337+adjust = coerce (M.adjust :: (a -> a) -> k -> M.Map k a -> M.Map k a)
338+{-# INLINE adjust #-}
340+adjustWithKey :: forall k a. Ord k => (k -> a -> a) -> k -> MonoidalMap k a -> MonoidalMap k a
341+adjustWithKey = coerce (M.adjustWithKey :: (k -> a -> a) -> k -> M.Map k a -> M.Map k a)
342+{-# INLINE adjustWithKey #-}
344+update :: forall k a. Ord k => (a -> Maybe a) -> k -> MonoidalMap k a -> MonoidalMap k a
345+update = coerce (M.update :: (a -> Maybe a) -> k -> M.Map k a -> M.Map k a)
346+{-# INLINE update #-}
348+updateWithKey :: forall k a. Ord k => (k -> a -> Maybe a) -> k -> MonoidalMap k a -> MonoidalMap k a
349+updateWithKey = coerce (M.updateWithKey :: (k -> a -> Maybe a) -> k -> M.Map k a -> M.Map k a)
350+{-# INLINE updateWithKey #-}
352+updateLookupWithKey :: forall k a. Ord k => (k -> a -> Maybe a) -> k -> MonoidalMap k a -> (Maybe a, MonoidalMap k a)
353+updateLookupWithKey = coerce (M.updateLookupWithKey :: (k -> a -> Maybe a) -> k -> M.Map k a -> (Maybe a, M.Map k a))
354+{-# INLINE updateLookupWithKey #-}
356+alter :: forall k a. Ord k => (Maybe a -> Maybe a) -> k -> MonoidalMap k a -> MonoidalMap k a
357+alter = coerce (M.alter :: (Maybe a -> Maybe a) -> k -> M.Map k a -> M.Map k a)
360+unionWith :: forall k a. Ord k => (a -> a -> a) -> MonoidalMap k a -> MonoidalMap k a -> MonoidalMap k a
361+unionWith = coerce (M.unionWith :: (a -> a -> a) -> M.Map k a -> M.Map k a -> M.Map k a)
362+{-# INLINE unionWith #-}
364+unionWithKey :: forall k a. Ord k => (k -> a -> a -> a) -> MonoidalMap k a -> MonoidalMap k a -> MonoidalMap k a
365+unionWithKey = coerce (M.unionWithKey :: (k -> a -> a -> a) -> M.Map k a -> M.Map k a -> M.Map k a)
366+{-# INLINE unionWithKey #-}
368+unionsWith :: forall k a. Ord k => (a -> a -> a) -> [MonoidalMap k a] -> MonoidalMap k a
369+unionsWith = coerce (M.unionsWith :: (a -> a -> a) -> [M.Map k a] -> M.Map k a)
370+{-# INLINE unionsWith #-}
372+difference :: forall k a b. Ord k => MonoidalMap k a -> MonoidalMap k b -> MonoidalMap k a
374+{-# INLINE difference #-}
376+differenceWith :: forall k a b. Ord k => (a -> b -> Maybe a) -> MonoidalMap k a -> MonoidalMap k b -> MonoidalMap k a
377+differenceWith = coerce (M.differenceWith :: (a -> b -> Maybe a) -> M.Map k a -> M.Map k b -> M.Map k a)
378+{-# INLINE differenceWith #-}
380+differenceWithKey :: forall k a b. Ord k => (k -> a -> b -> Maybe a) -> MonoidalMap k a -> MonoidalMap k b -> MonoidalMap k a
381+differenceWithKey = coerce (M.differenceWithKey :: (k -> a -> b -> Maybe a) -> M.Map k a -> M.Map k b -> M.Map k a)
382+{-# INLINE differenceWithKey #-}
384+intersectionWith :: forall k a b c. Ord k => (a -> b -> c) -> MonoidalMap k a -> MonoidalMap k b -> MonoidalMap k c
385+intersectionWith = coerce (M.intersectionWith :: (a -> b -> c) -> M.Map k a -> M.Map k b -> M.Map k c)
386+{-# INLINE intersectionWith #-}
388+intersectionWithKey :: forall k a b c. Ord k => (k -> a -> b -> c) -> MonoidalMap k a -> MonoidalMap k b -> MonoidalMap k c
389+intersectionWithKey = coerce (M.intersectionWithKey :: (k -> a -> b -> c) -> M.Map k a -> M.Map k b -> M.Map k c)
390+{-# INLINE intersectionWithKey #-}
392+mergeWithKey :: forall k a b c. Ord k => (k -> a -> b -> Maybe c) -> (MonoidalMap k a -> MonoidalMap k c) -> (MonoidalMap k b -> MonoidalMap k c) -> MonoidalMap k a -> MonoidalMap k b -> MonoidalMap k c
393+mergeWithKey = coerce (M.mergeWithKey :: (k -> a -> b -> Maybe c) -> (M.Map k a -> M.Map k c) -> (M.Map k b -> M.Map k c) -> M.Map k a -> M.Map k b -> M.Map k c)
394+{-# INLINE mergeWithKey #-}
396+map :: (a -> b) -> MonoidalMap k a -> MonoidalMap k b
400+mapWithKey :: forall k a b. (k -> a -> b) -> MonoidalMap k a -> MonoidalMap k b
401+mapWithKey = coerce (M.mapWithKey :: (k -> a -> b) -> M.Map k a -> M.Map k b)
402+{-# INLINE mapWithKey #-}
404+traverseWithKey :: Applicative t => (k -> a -> t b) -> MonoidalMap k a -> t (MonoidalMap k b)
405+traverseWithKey = itraverse
406+{-# INLINE traverseWithKey #-}
408+mapAccum :: forall k a b c. (a -> b -> (a, c)) -> a -> MonoidalMap k b -> (a, MonoidalMap k c)
409+mapAccum = coerce (M.mapAccum :: (a -> b -> (a, c)) -> a -> M.Map k b -> (a, M.Map k c))
410+{-# INLINE mapAccum #-}
412+mapAccumWithKey :: forall k a b c. (a -> k -> b -> (a, c)) -> a -> MonoidalMap k b -> (a, MonoidalMap k c)
413+mapAccumWithKey = coerce (M.mapAccumWithKey :: (a -> k -> b -> (a, c)) -> a -> M.Map k b -> (a, M.Map k c))
414+{-# INLINE mapAccumWithKey #-}
416+mapAccumRWithKey :: forall k a b c. (a -> k -> b -> (a, c)) -> a -> MonoidalMap k b -> (a, MonoidalMap k c)
417+mapAccumRWithKey = coerce (M.mapAccumRWithKey :: (a -> k -> b -> (a, c)) -> a -> M.Map k b -> (a, M.Map k c))
418+{-# INLINE mapAccumRWithKey #-}
420+mapKeys :: forall k1 k2 a. Ord k2 => (k1 -> k2) -> MonoidalMap k1 a -> MonoidalMap k2 a
421+mapKeys = coerce (M.mapKeys :: (k1 -> k2) -> M.Map k1 a -> M.Map k2 a)
422+{-# INLINE mapKeys #-}
424+mapKeysWith :: forall k1 k2 a. Ord k2 => (a -> a -> a) -> (k1 -> k2) -> MonoidalMap k1 a -> MonoidalMap k2 a
425+mapKeysWith = coerce (M.mapKeysWith :: (a -> a -> a) -> (k1 -> k2) -> M.Map k1 a -> M.Map k2 a)
426+{-# INLINE mapKeysWith #-}
428+mapKeysMonotonic :: forall k1 k2 a. (k1 -> k2) -> MonoidalMap k1 a -> MonoidalMap k2 a
429+mapKeysMonotonic = coerce (M.mapKeysMonotonic :: (k1 -> k2) -> M.Map k1 a -> M.Map k2 a)
430+{-# INLINE mapKeysMonotonic #-}
432+foldr :: forall k a b. (a -> b -> b) -> b -> MonoidalMap k a -> b
433+foldr = coerce (M.foldr :: (a -> b -> b) -> b -> M.Map k a -> b)
436+foldl :: forall k a b. (a -> b -> a) -> a -> MonoidalMap k b -> a
437+foldl = coerce (M.foldl :: (a -> b -> a) -> a -> M.Map k b -> a)
440+foldrWithKey :: forall k a b. (k -> a -> b -> b) -> b -> MonoidalMap k a -> b
441+foldrWithKey = coerce (M.foldrWithKey :: (k -> a -> b -> b) -> b -> M.Map k a -> b)
442+{-# INLINE foldrWithKey #-}
444+foldlWithKey :: forall k a b. (a -> k -> b -> a) -> a -> MonoidalMap k b -> a
445+foldlWithKey = coerce (M.foldlWithKey :: (a -> k -> b -> a) -> a -> M.Map k b -> a)
446+{-# INLINE foldlWithKey #-}
448+foldMapWithKey :: forall k a m. Monoid m => (k -> a -> m) -> MonoidalMap k a -> m
449+foldMapWithKey = coerce (M.foldMapWithKey :: Monoid m => (k -> a -> m) -> M.Map k a -> m)
450+{-# INLINE foldMapWithKey #-}
452+foldr' :: forall k a b. (a -> b -> b) -> b -> MonoidalMap k a -> b
453+foldr' = coerce (M.foldr' :: (a -> b -> b) -> b -> M.Map k a -> b)
454+{-# INLINE foldr' #-}
456+foldl' :: forall k a b. (a -> b -> a) -> a -> MonoidalMap k b -> a
457+foldl' = coerce (M.foldl' :: (a -> b -> a) -> a -> M.Map k b -> a)
458+{-# INLINE foldl' #-}
460+foldrWithKey' :: forall k a b. (k -> a -> b -> b) -> b -> MonoidalMap k a -> b
461+foldrWithKey' = coerce (M.foldrWithKey' :: (k -> a -> b -> b) -> b -> M.Map k a -> b)
462+{-# INLINE foldrWithKey' #-}
464+foldlWithKey' :: forall k a b. (a -> k -> b -> a) -> a -> MonoidalMap k b -> a
465+foldlWithKey' = coerce (M.foldlWithKey' :: (a -> k -> b -> a) -> a -> M.Map k b -> a)
466+{-# INLINE foldlWithKey' #-}
468+keysSet :: forall k a. MonoidalMap k a -> Set k
469+keysSet = coerce (M.keysSet :: M.Map k a -> Set k)
470+{-# INLINE keysSet #-}
472+fromSet :: forall k a. (k -> a) -> Set k -> MonoidalMap k a
473+fromSet = coerce (M.fromSet :: (k -> a) -> Set k -> M.Map k a)
474+{-# INLINE fromSet #-}
476+toList :: forall k a. MonoidalMap k a -> [(k, a)]
477+toList = coerce (M.toList :: M.Map k a -> [(k, a)])
478+{-# INLINE toList #-}
480+fromList :: forall k a. Ord k => [(k, a)] -> MonoidalMap k a
481+fromList = coerce (M.fromList :: [(k, a)] -> M.Map k a)
482+{-# INLINE fromList #-}
484+fromListWith :: forall k a. Ord k => (a -> a -> a) -> [(k, a)] -> MonoidalMap k a
485+fromListWith = coerce (M.fromListWith :: (a -> a -> a) -> [(k, a)] -> M.Map k a)
486+{-# INLINE fromListWith #-}
488+fromListWithKey :: forall k a. Ord k => (k -> a -> a -> a) -> [(k, a)] -> MonoidalMap k a
489+fromListWithKey = coerce (M.fromListWithKey :: (k -> a -> a -> a) -> [(k, a)] -> M.Map k a)
490+{-# INLINE fromListWithKey #-}
492+toAscList :: forall k a. MonoidalMap k a -> [(k, a)]
493+toAscList = coerce (M.toAscList :: M.Map k a -> [(k, a)])
494+{-# INLINE toAscList #-}
496+toDescList :: forall k a. MonoidalMap k a -> [(k, a)]
497+toDescList = coerce (M.toDescList :: M.Map k a -> [(k, a)])
498+{-# INLINE toDescList #-}
500+fromAscList :: forall k a. Eq k => [(k, a)] -> MonoidalMap k a
501+fromAscList = coerce (M.fromAscList :: [(k, a)] -> M.Map k a)
502+{-# INLINE fromAscList #-}
504+fromAscListWith :: forall k a. Eq k => (a -> a -> a) -> [(k, a)] -> MonoidalMap k a
505+fromAscListWith = coerce (M.fromAscListWith :: (a -> a -> a) -> [(k, a)] -> M.Map k a)
506+{-# INLINE fromAscListWith #-}
508+fromAscListWithKey :: forall k a. Eq k => (k -> a -> a -> a) -> [(k, a)] -> MonoidalMap k a
509+fromAscListWithKey = coerce (M.fromAscListWithKey :: (k -> a -> a -> a) -> [(k, a)] -> M.Map k a)
510+{-# INLINE fromAscListWithKey #-}
512+fromDistinctAscList :: forall k a. [(k, a)] -> MonoidalMap k a
513+fromDistinctAscList = coerce (M.fromDistinctAscList :: [(k, a)] -> M.Map k a)
514+{-# INLINE fromDistinctAscList #-}
516+filter :: forall k a. (a -> Bool) -> MonoidalMap k a -> MonoidalMap k a
517+filter = coerce (M.filter :: (a -> Bool) -> M.Map k a -> M.Map k a)
518+{-# INLINE filter #-}
520+filterWithKey :: forall k a. (k -> a -> Bool) -> MonoidalMap k a -> MonoidalMap k a
521+filterWithKey = coerce (M.filterWithKey :: (k -> a -> Bool) -> M.Map k a -> M.Map k a)
522+{-# INLINE filterWithKey #-}
524+partition :: forall k a. (a -> Bool) -> MonoidalMap k a -> (MonoidalMap k a, MonoidalMap k a)
525+partition = coerce (M.partition :: (a -> Bool) -> M.Map k a -> (M.Map k a, M.Map k a))
526+{-# INLINE partition #-}
528+partitionWithKey :: forall k a. (k -> a -> Bool) -> MonoidalMap k a -> (MonoidalMap k a, MonoidalMap k a)
529+partitionWithKey = coerce (M.partitionWithKey :: (k -> a -> Bool) -> M.Map k a -> (M.Map k a, M.Map k a))
530+{-# INLINE partitionWithKey #-}
532+mapMaybe :: forall k a b. (a -> Maybe b) -> MonoidalMap k a -> MonoidalMap k b
533+mapMaybe = coerce (M.mapMaybe :: (a -> Maybe b) -> M.Map k a -> M.Map k b)
534+{-# INLINE mapMaybe #-}
536+mapMaybeWithKey :: forall k a b. (k -> a -> Maybe b) -> MonoidalMap k a -> MonoidalMap k b
537+mapMaybeWithKey = coerce (M.mapMaybeWithKey :: (k -> a -> Maybe b) -> M.Map k a -> M.Map k b)
538+{-# INLINE mapMaybeWithKey #-}
540+mapEither :: forall k a b c. (a -> Either b c) -> MonoidalMap k a -> (MonoidalMap k b, MonoidalMap k c)
541+mapEither = coerce (M.mapEither :: (a -> Either b c) -> M.Map k a -> (M.Map k b, M.Map k c))
542+{-# INLINE mapEither #-}
544+mapEitherWithKey :: forall k a b c. (k -> a -> Either b c) -> MonoidalMap k a -> (MonoidalMap k b, MonoidalMap k c)
545+mapEitherWithKey = coerce (M.mapEitherWithKey :: (k -> a -> Either b c) -> M.Map k a -> (M.Map k b, M.Map k c))
546+{-# INLINE mapEitherWithKey #-}
548+split :: forall k a. Ord k => k -> MonoidalMap k a -> (MonoidalMap k a, MonoidalMap k a)
549+split = coerce (M.split :: k -> M.Map k a -> (M.Map k a, M.Map k a))
552+splitLookup :: forall k a. Ord k => k -> MonoidalMap k a -> (MonoidalMap k a, Maybe a, MonoidalMap k a)
553+splitLookup = coerce (M.splitLookup :: k -> M.Map k a -> (M.Map k a, Maybe a, M.Map k a))
554+{-# INLINE splitLookup #-}
556+splitRoot :: forall k a. MonoidalMap k a -> [MonoidalMap k a]
557+splitRoot = coerce (M.splitRoot :: M.Map k a -> [M.Map k a])
558+{-# INLINE splitRoot #-}
560+isSubmapOf :: forall k a. (Ord k, Eq a) => MonoidalMap k a -> MonoidalMap k a -> Bool
561+isSubmapOf = coerce (M.isSubmapOf :: M.Map k a -> M.Map k a -> Bool)
562+{-# INLINE isSubmapOf #-}
564+isSubmapOfBy :: forall k a b. Ord k => (a -> b -> Bool) -> MonoidalMap k a -> MonoidalMap k b -> Bool
565+isSubmapOfBy = coerce (M.isSubmapOfBy :: (a -> b -> Bool) -> M.Map k a -> M.Map k b -> Bool)
566+{-# INLINE isSubmapOfBy #-}
568+isProperSubmapOf :: forall k a. (Ord k, Eq a) => MonoidalMap k a -> MonoidalMap k a -> Bool
569+isProperSubmapOf = coerce (M.isProperSubmapOf :: M.Map k a -> M.Map k a -> Bool)
570+{-# INLINE isProperSubmapOf #-}
572+isProperSubmapOfBy :: forall k a b. Ord k => (a -> b -> Bool) -> MonoidalMap k a -> MonoidalMap k b -> Bool
573+isProperSubmapOfBy = coerce (M.isProperSubmapOfBy :: (a -> b -> Bool) -> M.Map k a -> M.Map k b -> Bool)
574+{-# INLINE isProperSubmapOfBy #-}
576+lookupIndex :: forall k a. Ord k => k -> MonoidalMap k a -> Maybe Int
577+lookupIndex = coerce (M.lookupIndex :: k -> M.Map k a -> Maybe Int)
578+{-# INLINE lookupIndex #-}
580+findIndex :: forall k a. Ord k => k -> MonoidalMap k a -> Int
581+findIndex = coerce (M.findIndex :: k -> M.Map k a -> Int)
582+{-# INLINE findIndex #-}
584+elemAt :: forall k a. Int -> MonoidalMap k a -> (k, a)
585+elemAt = coerce (M.elemAt :: Int -> M.Map k a -> (k, a))
586+{-# INLINE elemAt #-}
588+updateAt :: forall k a. (k -> a -> Maybe a) -> Int -> MonoidalMap k a -> MonoidalMap k a
589+updateAt = coerce (M.updateAt :: (k -> a -> Maybe a) -> Int -> M.Map k a -> M.Map k a)
590+{-# INLINE updateAt #-}
592+deleteAt :: forall k a. Int -> MonoidalMap k a -> MonoidalMap k a
593+deleteAt = coerce (M.deleteAt :: Int -> M.Map k a -> M.Map k a)
594+{-# INLINE deleteAt #-}
596+findMin :: forall k a. MonoidalMap k a -> (k, a)
597+findMin = coerce (M.findMin :: M.Map k a -> (k, a))
598+{-# INLINE findMin #-}
600+findMax :: forall k a. MonoidalMap k a -> (k, a)
601+findMax = coerce (M.findMax :: M.Map k a -> (k, a))
602+{-# INLINE findMax #-}
604+deleteMin :: forall k a. MonoidalMap k a -> MonoidalMap k a
605+deleteMin = coerce (M.deleteMin :: M.Map k a -> M.Map k a)
606+{-# INLINE deleteMin #-}
608+deleteMax :: forall k a. MonoidalMap k a -> MonoidalMap k a
609+deleteMax = coerce (M.deleteMax :: M.Map k a -> M.Map k a)
610+{-# INLINE deleteMax #-}
612+deleteFindMin :: forall k a. MonoidalMap k a -> ((k, a), MonoidalMap k a)
613+deleteFindMin = coerce (M.deleteFindMin :: M.Map k a -> ((k, a), M.Map k a))
614+{-# INLINE deleteFindMin #-}
616+deleteFindMax :: forall k a. MonoidalMap k a -> ((k, a), MonoidalMap k a)
617+deleteFindMax = coerce (M.deleteFindMax :: M.Map k a -> ((k, a), M.Map k a))
618+{-# INLINE deleteFindMax #-}
620+updateMin :: forall k a. (a -> Maybe a) -> MonoidalMap k a -> MonoidalMap k a
621+updateMin = coerce (M.updateMin :: (a -> Maybe a) -> M.Map k a -> M.Map k a)
622+{-# INLINE updateMin #-}
624+updateMax :: forall k a. (a -> Maybe a) -> MonoidalMap k a -> MonoidalMap k a
625+updateMax = coerce (M.updateMax :: (a -> Maybe a) -> M.Map k a -> M.Map k a)
626+{-# INLINE updateMax #-}
628+updateMinWithKey :: forall k a. (k -> a -> Maybe a) -> MonoidalMap k a -> MonoidalMap k a
629+updateMinWithKey = coerce (M.updateMinWithKey :: (k -> a -> Maybe a) -> M.Map k a -> M.Map k a)
630+{-# INLINE updateMinWithKey #-}
632+updateMaxWithKey :: forall k a. (k -> a -> Maybe a) -> MonoidalMap k a -> MonoidalMap k a
633+updateMaxWithKey = coerce (M.updateMaxWithKey :: (k -> a -> Maybe a) -> M.Map k a -> M.Map k a)
634+{-# INLINE updateMaxWithKey #-}
636+minView :: forall k a. MonoidalMap k a -> Maybe (a, MonoidalMap k a)
637+minView = coerce (M.minView :: M.Map k a -> Maybe (a, M.Map k a))
638+{-# INLINE minView #-}
640+maxView :: forall k a. MonoidalMap k a -> Maybe (a, MonoidalMap k a)
641+maxView = coerce (M.maxView :: M.Map k a -> Maybe (a, M.Map k a))
642+{-# INLINE maxView #-}
644+minViewWithKey :: forall k a. MonoidalMap k a -> Maybe ((k, a), MonoidalMap k a)
645+minViewWithKey = coerce (M.minViewWithKey :: M.Map k a -> Maybe ((k, a), M.Map k a))
646+{-# INLINE minViewWithKey #-}
648+maxViewWithKey :: forall k a. MonoidalMap k a -> Maybe ((k, a), MonoidalMap k a)
649+maxViewWithKey = coerce (M.maxViewWithKey :: M.Map k a -> Maybe ((k, a), M.Map k a))
650+{-# INLINE maxViewWithKey #-}
652+-- showTree :: forall k a. (Show k, Show a) => MonoidalMap k a -> String
653+-- showTree = coerce (M.showTree :: (Show k, Show a) => M.Map k a -> String)
654+-- {-# INLINE showTree #-}
656+-- showTreeWith :: forall k a. (k -> a -> String) -> Bool -> Bool -> MonoidalMap k a -> String
657+-- showTreeWith = coerce (M.showTreeWith :: (k -> a -> String) -> Bool -> Bool -> M.Map k a -> String)
658+-- {-# INLINE showTreeWith #-}
660+valid :: forall k a. Ord k => MonoidalMap k a -> Bool
661+valid = coerce (M.valid :: Ord k => M.Map k a -> Bool)