git.iko.soy/monoidal-containers
on master help sign in
Using mappend in fromList
commit7cf33e8aedb5886466bba817a4b84e46859b1ab5 authorKirill Zaborsky <qrilka@gmail.com> dateFri 22 Jul 2016, 17:56 (10 years ago) parent5208321
1 file changed+3−3
src/Data/HashMap/Monoidal.hs+3−3
src/Data/HashMap/Monoidal.hs+3−3
@@ -165,9 +165,9 @@ keys = M.keys . unpack
165165{-# INLINE keys #-}
166166
167167-- | /O(n*log n)/. Construct a map with the supplied mappings. If the list
168−-- contains duplicate mappings, the later mappings take precedence.
169−fromList :: (Eq k, Hashable k) => [(k,a)] -> MonoidalHashMap k a
170−fromList = pack . M.fromList
168+-- contains duplicate mappings, values will be merged using (mappend newVal oldVal).
169+fromList :: (Eq k, Hashable k, Monoid a) => [(k,a)] -> MonoidalHashMap k a
170+fromList = pack . M.fromListWith mappend
171171{-# INLINE fromList #-}
172172
173173-- | /O(n*log n)/. Construct a map with the supplied mappings. If the list