@@ -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 #-}