git.iko.soy/monoidal-containers
on master help sign in
Using mappend in fromList
7cf33e8Kirill Zaborsky
src/Data/HashMap/Monoidal.hs+3−3
@@ -165,9 +165,9 @@ keys = M.keys . unpack
165{-# INLINE keys #-}
165{-# INLINE keys #-}
166
166
167-- | /O(n*log n)/. Construct a map with the supplied mappings. If the list
167-- | /O(n*log n)/. Construct a map with the supplied mappings. If the list
168−-- contains duplicate mappings, the later mappings take precedence.
168+-- contains duplicate mappings, values will be merged using (mappend newVal oldVal).
169−fromList :: (Eq k, Hashable k) => [(k,a)] -> MonoidalHashMap k a
169+fromList :: (Eq k, Hashable k, Monoid a) => [(k,a)] -> MonoidalHashMap k a
170−fromList = pack . M.fromList
170+fromList = pack . M.fromListWith mappend
171{-# INLINE fromList #-}
171{-# INLINE fromList #-}
172
172
173-- | /O(n*log n)/. Construct a map with the supplied mappings. If the list
173-- | /O(n*log n)/. Construct a map with the supplied mappings. If the list