2{-# LANGUAGE FlexibleContexts #-}
3{-# LANGUAGE FlexibleInstances #-}
4{-# LANGUAGE MultiParamTypeClasses #-}
5{-# LANGUAGE PatternSynonyms #-}
6{-# LANGUAGE RoleAnnotations #-}
7{-# LANGUAGE ScopedTypeVariables #-}
8{-# LANGUAGE TypeFamilies #-}
9{-# OPTIONS_GHC -fno-warn-orphans #-}
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.
19 ( module Data.AppendMap
20 , module Data.Map.Monoidal
23import Prelude hiding (null)
28#if MIN_VERSION_containers(0,5,11)
29import qualified Data.Map.Internal.Debug as Map (showTree, showTreeWith)
31import qualified Data.Map as Map (showTree, showTreeWith)
33import qualified Data.Witherable as W
34import Data.Map.Monoidal
35import qualified Data.Map.Monoidal as MonoidalMap
38{-# DEPRECATED AppendMap "Use 'MonoidalMap' instead" #-}
39-- | AppendMap is a synonym for 'Data.Map.Monoidal.MonoidalMap'
40type AppendMap = MonoidalMap
42{-# DEPRECATED _unAppendMap "Use 'getMonoidalMap' instead" #-}
43-- | A synonym for 'getMonoidalMap'
44_unAppendMap :: MonoidalMap k v -> Map k v
45_unAppendMap = getMonoidalMap
47-- | Pattern synonym for 'MonoidalMap'
48pattern AppendMap :: Map k v -> MonoidalMap k v
49pattern AppendMap m = MonoidalMap m
51#if !MIN_VERSION_witherable(0,3,2)
52instance W.Filterable (MonoidalMap k) where
53 mapMaybe = MonoidalMap.mapMaybe
56-- | Deletes a key, returning 'Nothing' if the result is empty.
57nonEmptyDelete :: Ord k => k -> MonoidalMap k a -> Maybe (MonoidalMap k a)
59 let deleted = delete k vs
64-- | Like 'mapMaybe' but indicates whether the resulting container is empty
65mapMaybeNoNull :: (a -> Maybe b)
66 -> MonoidalMap token a
67 -> Maybe (MonoidalMap token b)
69 let bs = mapMaybe f as
74-- TODO: Move instances to `Data.Patch`
75-- | Displays a 'MonoidalMap' as a tree. See 'Data.Map.Lazy.showTree' for details.
76showTree :: forall k a. (Show k, Show a) => MonoidalMap k a -> String
77showTree = coerce (Map.showTree :: Map k a -> String)
79-- | Displays a 'MonoidalMap' as a tree, using the supplied function to convert nodes to string.
80showTreeWith :: forall k a. (k -> a -> String) -> Bool -> Bool -> MonoidalMap k a -> String
81showTreeWith = coerce (Map.showTreeWith :: (k -> a -> String) -> Bool -> Bool -> Map k a -> String)
83instance Default (MonoidalMap k a) where
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list