@@ -98,11 +98,11 @@ instance (Eq k, Hashable k, Semigroup a) => Semigroup (MonoidalHashMap k a) wher
98 MonoidalHashMap a <> MonoidalHashMap b = MonoidalHashMap $ M.unionWith (<>) a b
98 MonoidalHashMap a <> MonoidalHashMap b = MonoidalHashMap $ M.unionWith (<>) a b
99 {-# INLINE (<>) #-}
99 {-# INLINE (<>) #-}
101−instance (Eq k, Hashable k, Monoid a) => Monoid (MonoidalHashMap k a) where
101+instance (Eq k, Hashable k, Semigroup a) => Monoid (MonoidalHashMap k a) where
102 mempty = MonoidalHashMap mempty
102 mempty = MonoidalHashMap mempty
103 {-# INLINE mempty #-}
103 {-# INLINE mempty #-}
104#if !(MIN_VERSION_base(4,11,0))
104#if !(MIN_VERSION_base(4,11,0))
105− mappend (MonoidalHashMap a) (MonoidalHashMap b) = MonoidalHashMap $ M.unionWith mappend a b
105+ mappend (MonoidalHashMap a) (MonoidalHashMap b) = MonoidalHashMap $ M.unionWith (<>) a b
106 {-# INLINE mappend #-}
106 {-# INLINE mappend #-}
@@ -113,9 +113,9 @@ instance Newtype (MonoidalHashMap k a) (M.HashMap k a) where
113 {-# INLINE unpack #-}
113 {-# INLINE unpack #-}
115#if MIN_VERSION_base(4,7,0)
115#if MIN_VERSION_base(4,7,0)
116−instance (Eq k, Hashable k, Monoid a) => Exts.IsList (MonoidalHashMap k a) where
116+instance (Eq k, Hashable k, Semigroup a) => Exts.IsList (MonoidalHashMap k a) where
117 type Item (MonoidalHashMap k a) = (k, a)
117 type Item (MonoidalHashMap k a) = (k, a)
118− fromList = MonoidalHashMap . M.fromListWith mappend
118+ fromList = MonoidalHashMap . M.fromListWith (<>)
119 {-# INLINE fromList #-}
119 {-# INLINE fromList #-}
120 toList = M.toList . unpack
120 toList = M.toList . unpack
121 {-# INLINE toList #-}
121 {-# INLINE toList #-}
@@ -173,8 +173,8 @@ keys = M.keys . unpack
174-- | /O(n*log n)/. Construct a map with the supplied mappings. If the list
174-- | /O(n*log n)/. Construct a map with the supplied mappings. If the list
175-- contains duplicate mappings, values will be merged using (mappend newVal oldVal).
175-- contains duplicate mappings, values will be merged using (mappend newVal oldVal).
176−fromList :: (Eq k, Hashable k, Monoid a) => [(k,a)] -> MonoidalHashMap k a
176+fromList :: (Eq k, Hashable k, Semigroup a) => [(k,a)] -> MonoidalHashMap k a
177−fromList = pack . M.fromListWith mappend
177+fromList = pack . M.fromListWith (<>)
178{-# INLINE fromList #-}
178{-# INLINE fromList #-}
180-- | /O(n*log n)/. Return a list of this map's elements. The list is produced
180-- | /O(n*log n)/. Return a list of this map's elements. The list is produced
@@ -218,7 +218,7 @@ modify f k = pack
219-- | /O(log n)/. Modify a value on some key with a function, providing
219-- | /O(log n)/. Modify a value on some key with a function, providing
220-- a default value if that key doesn't exist.
220-- a default value if that key doesn't exist.
221−modifyDef :: (Monoid a, Hashable k, Eq k)
221+modifyDef :: (Semigroup a, Hashable k, Eq k)
222 => a -> (a -> a)
222 => a -> (a -> a)
223 -> k -> MonoidalHashMap k a
223 -> k -> MonoidalHashMap k a
224 -> MonoidalHashMap k a
224 -> MonoidalHashMap k a
@@ -229,7 +229,7 @@ modifyDef d f k = pack
230-- | /O(n)/. Map a function to each key of a map, if it will result
230-- | /O(n)/. Map a function to each key of a map, if it will result
231-- in duplicated mappings, their values will be merged in unspecified order
231-- in duplicated mappings, their values will be merged in unspecified order
232−mapKeys :: (Monoid a, Hashable k, Eq k, Hashable k', Eq k')
232+mapKeys :: (Semigroup a, Hashable k, Eq k, Hashable k', Eq k')
233 => (k -> k') -> MonoidalHashMap k a -> MonoidalHashMap k' a
233 => (k -> k') -> MonoidalHashMap k a -> MonoidalHashMap k' a
234mapKeys f = fromList
234mapKeys f = fromList
235 . fmap (\(k, v) -> (f k, v))
235 . fmap (\(k, v) -> (f k, v))