@@ -164,13 +164,13 @@ keys = M.keys . unpack
164164{-# INLINE keys #-}
165165
166166-- | /O(n*log n)/. Construct a map with the supplied mappings. If the list
167−-- contains duplicate mappings, the later mappings take precedence.
168−fromList :: (Eq k, Hashable k) => [(k,a)] -> MonoidalHashMap k a
169−fromList = pack . M.fromList
167+-- contains duplicate mappings, values will be merged using (mappend newVal oldVal).
168+fromList :: (Eq k, Hashable k, Monoid a) => [(k,a)] -> MonoidalHashMap k a
169+fromList = pack . M.fromListWith mappend
170170{-# INLINE fromList #-}
171171
172−-- | /O(n*log n)/. Construct a map with the supplied mappings. If the list
173−-- contains duplicate mappings, the later mappings take precedence.
172+-- | /O(n*log n)/. Return a list of this map's elements. The list is produced
173+-- lazily. The order of its elements is unspecified.
174174toList :: MonoidalHashMap k a -> [(k,a)]
175175toList = M.toList . unpack
176176{-# INLINE toList #-}
@@ -197,7 +197,8 @@ modifyDef d f k = pack
197197 . unpack
198198{-# INLINE modifyDef #-}
199199
200−-- | /O(n)/. Map a function to each key of a map
200+-- | /O(n)/. Map a function to each key of a map, if it will result
201+-- in duplicated mappings, their values will be merged in unspecified order
201202mapKeys :: (Monoid a, Hashable k, Eq k, Hashable k', Eq k')
202203 => (k -> k') -> MonoidalHashMap k a -> MonoidalHashMap k' a
203204mapKeys f = fromList