@@ -7,10 +7,14 @@
77{-# LANGUAGE ScopedTypeVariables #-}
88{-# LANGUAGE TypeFamilies #-}
99{-# OPTIONS_GHC -fno-warn-orphans #-}
10−-- | 'Data.Map' with a better 'Monoid' instance
11−--
12−-- 'Data.Map' has @mappend = union@, which is left-biased. AppendMap has
13−-- @mappend = unionWith mappend@ instead.
10+-- |
11+-- Module:
12+-- Data.AppendMap
13+-- Description:
14+-- Instances and convenience functions for 'Data.Map.Monoidal'. We use
15+-- monoidal-containers to take advantage of its better monoid instance.
16+-- 'Data.Map' has @mappend = union@, which is left-biased. 'MonoidalMap'
17+-- has @mappend = unionWith mappend@ instead.
1418module Data.AppendMap
1519 ( module Data.AppendMap
1620 , module Data.Map.Monoidal
@@ -30,12 +34,15 @@ import qualified Data.Witherable as W
3034import Data.Map.Monoidal
3135
3236{-# DEPRECATED AppendMap "Use 'MonoidalMap' instead" #-}
37+-- | AppendMap is a synonym for 'Data.Map.Monoidal.MonoidalMap'
3338type AppendMap = MonoidalMap
3439
3540{-# DEPRECATED _unAppendMap "Use 'getMonoidalMap' instead" #-}
41+-- | A synonym for 'getMonoidalMap'
3642_unAppendMap :: MonoidalMap k v -> Map k v
3743_unAppendMap = getMonoidalMap
3844
45+-- | Pattern synonym for 'MonoidalMap'
3946pattern AppendMap :: Map k v -> MonoidalMap k v
4047pattern AppendMap m = MonoidalMap m
4148
@@ -50,6 +57,7 @@ nonEmptyDelete k vs =
5057 then Nothing
5158 else Just deleted
5259
60+-- | Like 'mapMaybe' but indicates whether the resulting container is empty
5361mapMaybeNoNull :: (a -> Maybe b)
5462 -> MonoidalMap token a
5563 -> Maybe (MonoidalMap token b)
@@ -60,9 +68,11 @@ mapMaybeNoNull f as =
6068 else Just bs
6169
6270-- TODO: Move instances to `Reflex.Patch`
71+-- | Displays a 'MonoidalMap' as a tree. See 'Data.Map.Lazy.showTree' for details.
6372showTree :: forall k a. (Show k, Show a) => MonoidalMap k a -> String
6473showTree = coerce (Map.showTree :: Map k a -> String)
6574
75+-- | Displays a 'MonoidalMap' as a tree, using the supplied function to convert nodes to string.
6676showTreeWith :: forall k a. (k -> a -> String) -> Bool -> Bool -> MonoidalMap k a -> String
6777showTreeWith = coerce (Map.showTreeWith :: (k -> a -> String) -> Bool -> Bool -> Map k a -> String)
6878