git.iko.soy/monoidal-containers
on master help sign in
Add Map.assocs
commiteab1870554e3d6e94718ec1c1de6872c7267deca authorBen Gamari <ben@smart-cactus.org> dateMon 4 Jul 2016, 12:43 (10 years ago) parenta1b8ca9
1 file changed+6
src/Data/Map/Monoidal.hs+6
src/Data/Map/Monoidal.hs+6
@@ -23,6 +23,7 @@ module Data.Map.Monoidal
2323 , member
2424 , notMember
2525 , findWithDefault
26+ , assocs
2627 , elems
2728 , keys
2829 ) where
@@ -142,6 +143,11 @@ delete :: Ord k => k -> MonoidalMap k a -> MonoidalMap k a
142143delete k = _Wrapping' MM %~ M.delete k
143144{-# INLINE delete #-}
144145
146+-- | /O(n)/. Return all elements of the map and their keys
147+assocs :: MonoidalMap k a -> [(k,a)]
148+assocs = M.assocs . unpack
149+{-# INLINE assocs #-}
150+
145151-- | /O(n)/. Return all elements of the map in the ascending order of their
146152-- keys. Subject to list fusion.
147153elems :: MonoidalMap k a -> [a]