git.iko.soy/monoidal-containers
on master help sign in
Haddocks
commit3d959e1ebc1ca98e37ec5404b55fc827bd83ca9a authorBen Gamari <bgamari.foss@gmail.com> dateTue 20 Jan 2015, 11:35 (12 years ago) parent1ecb839
1 file changed+10
src/Data/Map/Monoidal.hs+10
src/Data/Map/Monoidal.hs+10
@@ -5,6 +5,15 @@
55{-# LANGUAGE DeriveTraversable #-}
66{-# LANGUAGE DeriveDataTypeable #-}
77
8+-- | This module provides a 'Data.Map' variant which uses the value's
9+-- 'Monoid' instance to accumulate conflicting entries when merging
10+-- 'Map's.
11+--
12+-- While some functions mirroring those of 'Data.Map' are provided
13+-- here for convenience, more specialized needs will likely want to use
14+-- either the @Newtype@ or @Wrapped@ instances to manipulate the
15+-- underlying 'Map'.
16+
817module Data.Map.Monoidal
918 ( MonoidalMap
1019 , singleton
@@ -66,6 +75,7 @@ instance Ord k => IsList (MonoidalMap k a) where
6675 {-# INLINE toList #-}
6776#endif
6877
78+-- | /O(1)/. A map with a single element.
6979singleton :: Ord k => k -> a -> MonoidalMap k a
7080singleton k a = MM $ M.singleton k a
7181{-# INLINE singleton #-}