monoidal-containers-0.1.1.0: Containers with monoidal accumulation

Safe HaskellNone
LanguageHaskell2010

Data.Map.Monoidal

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

data MonoidalMap k a Source

A Map with monoidal accumulation

Instances

Ord k => TraverseMin k (MonoidalMap k) Source 
Ord k => TraverseMax k (MonoidalMap k) Source 
Ord k => TraversableWithIndex k (MonoidalMap k) Source 
Ord k => FunctorWithIndex k (MonoidalMap k) Source 
Ord k => FoldableWithIndex k (MonoidalMap k) Source 
Functor (MonoidalMap k) Source 
Foldable (MonoidalMap k) Source 
Traversable (MonoidalMap k) Source 
Ord k => IsList (MonoidalMap k a) Source 
(Eq k, Eq a) => Eq (MonoidalMap k a) Source 
(Data k, Data a, Ord k) => Data (MonoidalMap k a) Source 
(Ord k, Ord a) => Ord (MonoidalMap k a) Source 
(Ord k, Read k, Read a) => Read (MonoidalMap k a) Source 
(Show k, Show a) => Show (MonoidalMap k a) Source 
(Ord k, Monoid a) => Monoid (MonoidalMap k a) Source 
(NFData k, NFData a) => NFData (MonoidalMap k a) Source 
Wrapped (MonoidalMap k a) Source 
AsEmpty (MonoidalMap k a) Source 
Ord k => Ixed (MonoidalMap k a) Source 
Ord k => At (MonoidalMap k a) Source 
Typeable (* -> * -> *) MonoidalMap Source 
Newtype (MonoidalMap k a) (Map k a) Source 
Each (MonoidalMap k a) (MonoidalMap k b) a b Source 
type Item (MonoidalMap k a) = (k, a) Source 
type Unwrapped (MonoidalMap k a) = Map k a Source 
type IxValue (MonoidalMap k a) = a Source 
type Index (MonoidalMap k a) = k Source 

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.

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.