monoidal-containers-0.3.0.2: Containers with monoidal accumulation

Safe HaskellNone
LanguageHaskell2010

Data.Map.Monoidal.Strict

Contents

Description

This module provides a Map variant which uses the value's Monoid instance to accumulate conflicting entries when merging Maps.

While some functions mirroring those of Map are provided here for convenience, more specialized needs will likely want to use either the Newtype or Wrapped instances to manipulate the underlying Map.

Synopsis

Documentation

newtype MonoidalMap k a Source #

A Map with monoidal accumulation

Constructors

MonoidalMap 

Fields

Instances

Ord k => TraverseMin k (MonoidalMap k) Source # 

Methods

traverseMin :: (Indexable k p, Applicative f) => p v (f v) -> MonoidalMap k v -> f (MonoidalMap k v)

Ord k => TraverseMax k (MonoidalMap k) Source # 

Methods

traverseMax :: (Indexable k p, Applicative f) => p v (f v) -> MonoidalMap k v -> f (MonoidalMap k v)

Ord k => TraversableWithIndex k (MonoidalMap k) Source # 

Methods

itraverse :: Applicative f => (k -> a -> f b) -> MonoidalMap k a -> f (MonoidalMap k b)

itraversed :: (Indexable k p, Applicative f) => p a (f b) -> MonoidalMap k a -> f (MonoidalMap k b)

Ord k => FunctorWithIndex k (MonoidalMap k) Source # 

Methods

imap :: (k -> a -> b) -> MonoidalMap k a -> MonoidalMap k b

imapped :: (Indexable k p, Settable f) => p a (f b) -> MonoidalMap k a -> f (MonoidalMap k b)

Ord k => FoldableWithIndex k (MonoidalMap k) Source # 

Methods

ifoldMap :: Monoid m => (k -> a -> m) -> MonoidalMap k a -> m

ifolded :: (Indexable k p, Contravariant f, Applicative f) => p a (f a) -> MonoidalMap k a -> f (MonoidalMap k a)

ifoldr :: (k -> a -> b -> b) -> b -> MonoidalMap k a -> b

ifoldl :: (k -> b -> a -> b) -> b -> MonoidalMap k a -> b

ifoldr' :: (k -> a -> b -> b) -> b -> MonoidalMap k a -> b

ifoldl' :: (k -> b -> a -> b) -> b -> MonoidalMap k a -> b

Functor (MonoidalMap k) Source # 

Methods

fmap :: (a -> b) -> MonoidalMap k a -> MonoidalMap k b #

(<$) :: a -> MonoidalMap k b -> MonoidalMap k a #

Foldable (MonoidalMap k) Source # 

Methods

fold :: Monoid m => MonoidalMap k m -> m #

foldMap :: Monoid m => (a -> m) -> MonoidalMap k a -> m #

foldr :: (a -> b -> b) -> b -> MonoidalMap k a -> b #

foldr' :: (a -> b -> b) -> b -> MonoidalMap k a -> b #

foldl :: (b -> a -> b) -> b -> MonoidalMap k a -> b #

foldl' :: (b -> a -> b) -> b -> MonoidalMap k a -> b #

foldr1 :: (a -> a -> a) -> MonoidalMap k a -> a #

foldl1 :: (a -> a -> a) -> MonoidalMap k a -> a #

toList :: MonoidalMap k a -> [a] #

null :: MonoidalMap k a -> Bool #

length :: MonoidalMap k a -> Int #

elem :: Eq a => a -> MonoidalMap k a -> Bool #

maximum :: Ord a => MonoidalMap k a -> a #

minimum :: Ord a => MonoidalMap k a -> a #

sum :: Num a => MonoidalMap k a -> a #

product :: Num a => MonoidalMap k a -> a #

Traversable (MonoidalMap k) Source # 

Methods

traverse :: Applicative f => (a -> f b) -> MonoidalMap k a -> f (MonoidalMap k b) #

sequenceA :: Applicative f => MonoidalMap k (f a) -> f (MonoidalMap k a) #

mapM :: Monad m => (a -> m b) -> MonoidalMap k a -> m (MonoidalMap k b) #

sequence :: Monad m => MonoidalMap k (m a) -> m (MonoidalMap k a) #

(Ord k, Monoid a) => IsList (MonoidalMap k a) Source # 

Associated Types

type Item (MonoidalMap k a) :: * #

Methods

fromList :: [Item (MonoidalMap k a)] -> MonoidalMap k a #

fromListN :: Int -> [Item (MonoidalMap k a)] -> MonoidalMap k a #

toList :: MonoidalMap k a -> [Item (MonoidalMap k a)] #

(Eq a, Eq k) => Eq (MonoidalMap k a) Source # 

Methods

(==) :: MonoidalMap k a -> MonoidalMap k a -> Bool #

(/=) :: MonoidalMap k a -> MonoidalMap k a -> Bool #

(Ord k, Data a, Data k) => Data (MonoidalMap k a) Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> MonoidalMap k a -> c (MonoidalMap k a) #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (MonoidalMap k a) #

toConstr :: MonoidalMap k a -> Constr #

dataTypeOf :: MonoidalMap k a -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c (MonoidalMap k a)) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (MonoidalMap k a)) #

gmapT :: (forall b. Data b => b -> b) -> MonoidalMap k a -> MonoidalMap k a #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> MonoidalMap k a -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> MonoidalMap k a -> r #

gmapQ :: (forall d. Data d => d -> u) -> MonoidalMap k a -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> MonoidalMap k a -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> MonoidalMap k a -> m (MonoidalMap k a) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> MonoidalMap k a -> m (MonoidalMap k a) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> MonoidalMap k a -> m (MonoidalMap k a) #

(Ord a, Ord k) => Ord (MonoidalMap k a) Source # 

Methods

compare :: MonoidalMap k a -> MonoidalMap k a -> Ordering #

(<) :: MonoidalMap k a -> MonoidalMap k a -> Bool #

(<=) :: MonoidalMap k a -> MonoidalMap k a -> Bool #

(>) :: MonoidalMap k a -> MonoidalMap k a -> Bool #

(>=) :: MonoidalMap k a -> MonoidalMap k a -> Bool #

max :: MonoidalMap k a -> MonoidalMap k a -> MonoidalMap k a #

min :: MonoidalMap k a -> MonoidalMap k a -> MonoidalMap k a #

(Read a, Read k, Ord k) => Read (MonoidalMap k a) Source # 
(Show a, Show k) => Show (MonoidalMap k a) Source # 

Methods

showsPrec :: Int -> MonoidalMap k a -> ShowS #

show :: MonoidalMap k a -> String #

showList :: [MonoidalMap k a] -> ShowS #

(Ord k, Monoid a) => Monoid (MonoidalMap k a) Source # 

Methods

mempty :: MonoidalMap k a #

mappend :: MonoidalMap k a -> MonoidalMap k a -> MonoidalMap k a #

mconcat :: [MonoidalMap k a] -> MonoidalMap k a #

(NFData a, NFData k) => NFData (MonoidalMap k a) Source # 

Methods

rnf :: MonoidalMap k a -> () #

Wrapped (MonoidalMap k a) Source # 

Associated Types

type Unwrapped (MonoidalMap k a) :: *

Methods

_Wrapped' :: Iso' (MonoidalMap k a) (Unwrapped (MonoidalMap k a))

AsEmpty (MonoidalMap k a) Source # 

Methods

_Empty :: Prism' (MonoidalMap k a) ()

Ord k => Ixed (MonoidalMap k a) Source # 

Methods

ix :: Index (MonoidalMap k a) -> Traversal' (MonoidalMap k a) (IxValue (MonoidalMap k a))

Ord k => At (MonoidalMap k a) Source # 

Methods

at :: Index (MonoidalMap k a) -> Lens' (MonoidalMap k a) (Maybe (IxValue (MonoidalMap k a)))

Newtype (MonoidalMap k a) (Map k a) Source # 

Methods

pack :: Map k a -> MonoidalMap k a

unpack :: MonoidalMap k a -> Map k a

Each (MonoidalMap k a) (MonoidalMap k b) a b Source # 

Methods

each :: Traversal (MonoidalMap k a) (MonoidalMap k b) a b

type Item (MonoidalMap k a) Source # 
type Item (MonoidalMap k a) = (k, a)
type Unwrapped (MonoidalMap k a) Source # 
type Unwrapped (MonoidalMap k a) = Map k a
type IxValue (MonoidalMap k a) Source # 
type IxValue (MonoidalMap k a) = a
type Index (MonoidalMap k a) Source # 
type Index (MonoidalMap k a) = k

Often-needed functions

singleton :: Ord k => k -> a -> MonoidalMap k a Source #

O(1). A map with a single element.

size :: MonoidalMap k a -> Int Source #

O(1). The number of elements in the map.

member :: Ord k => k -> MonoidalMap k a -> Bool Source #

O(log n). Is the key a member of the map? See also notMember.

notMember :: Ord k => k -> MonoidalMap k a -> Bool Source #

O(log n). Is the key not a member of the map? See also member.

findWithDefault :: Ord k => a -> k -> MonoidalMap k a -> a Source #

O(log n). The expression (findWithDefault def k map) returns the value at key k or returns default value def when the key is not in the map.

assocs :: MonoidalMap k a -> [(k, a)] Source #

O(n). Return all elements of the map and their keys

elems :: MonoidalMap k a -> [a] Source #

O(n). Return all elements of the map in the ascending order of their keys. Subject to list fusion.

keys :: MonoidalMap k a -> [k] Source #

O(n). Return all keys of the map in ascending order. Subject to list fusion.