monoidal-containers-0.6.3.0: Containers with monoidal accumulation
Safe Haskell None
Language Haskell2010

Data.HashMap.Monoidal

Description

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

While some functions mirroring those of HashMap 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 MonoidalHashMap k a Source #

A HashMap with monoidal accumulation

Instances

Instances details
( Eq k, Hashable k) => FunctorWithIndex k ( MonoidalHashMap k) Source #
Instance details

Defined in Data.HashMap.Monoidal

Methods

imap :: (k -> a -> b) -> MonoidalHashMap k a -> MonoidalHashMap k b Source #

( Eq k, Hashable k) => FoldableWithIndex k ( MonoidalHashMap k) Source #
Instance details

Defined in Data.HashMap.Monoidal

Methods

ifoldMap :: Monoid m => (k -> a -> m) -> MonoidalHashMap k a -> m Source #

ifoldMap' :: Monoid m => (k -> a -> m) -> MonoidalHashMap k a -> m Source #

ifoldr :: (k -> a -> b -> b) -> b -> MonoidalHashMap k a -> b Source #

ifoldl :: (k -> b -> a -> b) -> b -> MonoidalHashMap k a -> b Source #

ifoldr' :: (k -> a -> b -> b) -> b -> MonoidalHashMap k a -> b Source #

ifoldl' :: (k -> b -> a -> b) -> b -> MonoidalHashMap k a -> b Source #

( Eq k, Hashable k) => TraversableWithIndex k ( MonoidalHashMap k) Source #
Instance details

Defined in Data.HashMap.Monoidal

Methods

itraverse :: Applicative f => (k -> a -> f b) -> MonoidalHashMap k a -> f ( MonoidalHashMap k b) Source #

Functor ( MonoidalHashMap k) Source #
Instance details

Defined in Data.HashMap.Monoidal

Foldable ( MonoidalHashMap k) Source #
Instance details

Defined in Data.HashMap.Monoidal

Traversable ( MonoidalHashMap k) Source #
Instance details

Defined in Data.HashMap.Monoidal

Eq k => Eq1 ( MonoidalHashMap k) Source #
Instance details

Defined in Data.HashMap.Monoidal

Hashable k => Hashable1 ( MonoidalHashMap k) Source #
Instance details

Defined in Data.HashMap.Monoidal

( Eq k, Hashable k) => Semialign ( MonoidalHashMap k) Source #
Instance details

Defined in Data.HashMap.Monoidal

( Eq k, Hashable k) => Align ( MonoidalHashMap k) Source #
Instance details

Defined in Data.HashMap.Monoidal

( Eq k, Hashable k) => Unalign ( MonoidalHashMap k) Source #
Instance details

Defined in Data.HashMap.Monoidal

( Eq k, Hashable k) => Zip ( MonoidalHashMap k) Source #
Instance details

Defined in Data.HashMap.Monoidal

( Eq k, Hashable k) => Filterable ( MonoidalHashMap k) Source #
Instance details

Defined in Data.HashMap.Monoidal

( Eq k, Hashable k) => Witherable ( MonoidalHashMap k) Source #
Instance details

Defined in Data.HashMap.Monoidal

( Eq k, Hashable k, Semigroup a) => IsList ( MonoidalHashMap k a) Source #
Instance details

Defined in Data.HashMap.Monoidal

Associated Types

type Item ( MonoidalHashMap k a) Source #

( Eq k, Eq a) => Eq ( MonoidalHashMap k a) Source #
Instance details

Defined in Data.HashMap.Monoidal

( Data k, Data a, Eq k, Hashable k) => Data ( MonoidalHashMap k a) Source #
Instance details

Defined in Data.HashMap.Monoidal

Methods

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

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

toConstr :: MonoidalHashMap k a -> Constr Source #

dataTypeOf :: MonoidalHashMap k a -> DataType Source #

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

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

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

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

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

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

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

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

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

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

( Eq k, Hashable k, Read k, Read a) => Read ( MonoidalHashMap k a) Source #
Instance details

Defined in Data.HashMap.Monoidal

( Show k, Show a) => Show ( MonoidalHashMap k a) Source #
Instance details

Defined in Data.HashMap.Monoidal

( Eq k, Hashable k, Semigroup a) => Semigroup ( MonoidalHashMap k a) Source #
Instance details

Defined in Data.HashMap.Monoidal

( Eq k, Hashable k, Semigroup a) => Monoid ( MonoidalHashMap k a) Source #
Instance details

Defined in Data.HashMap.Monoidal

( Hashable k, Hashable a) => Hashable ( MonoidalHashMap k a) Source #
Instance details

Defined in Data.HashMap.Monoidal

( NFData k, NFData a) => NFData ( MonoidalHashMap k a) Source #
Instance details

Defined in Data.HashMap.Monoidal

( Eq k, Hashable k) => Ixed ( MonoidalHashMap k a) Source #
Instance details

Defined in Data.HashMap.Monoidal

( Eq k, Hashable k) => At ( MonoidalHashMap k a) Source #
Instance details

Defined in Data.HashMap.Monoidal

Wrapped ( MonoidalHashMap k a) Source #
Instance details

Defined in Data.HashMap.Monoidal

Associated Types

type Unwrapped ( MonoidalHashMap k a) Source #

AsEmpty ( MonoidalHashMap k a) Source #
Instance details

Defined in Data.HashMap.Monoidal

( Eq k, Hashable k) => Rewrapped ( HashMap k a) ( MonoidalHashMap k a) Source #
Instance details

Defined in Data.HashMap.Monoidal

( Eq k, Hashable k) => Rewrapped ( MonoidalHashMap k a) ( HashMap k a) Source #
Instance details

Defined in Data.HashMap.Monoidal

Newtype ( MonoidalHashMap k a) ( HashMap k a) Source #
Instance details

Defined in Data.HashMap.Monoidal

Each ( MonoidalHashMap k a) ( MonoidalHashMap k b) a b Source #
Instance details

Defined in Data.HashMap.Monoidal

type Item ( MonoidalHashMap k a) Source #
Instance details

Defined in Data.HashMap.Monoidal

type Item ( MonoidalHashMap k a) = (k, a)
type Index ( MonoidalHashMap k a) Source #
Instance details

Defined in Data.HashMap.Monoidal

type IxValue ( MonoidalHashMap k a) Source #
Instance details

Defined in Data.HashMap.Monoidal

type Unwrapped ( MonoidalHashMap k a) Source #
Instance details

Defined in Data.HashMap.Monoidal

Often-needed functions

toList :: MonoidalHashMap k a -> [(k, a)] Source #

O(n*log n) . Return a list of this map's elements. The list is produced lazily. The order of its elements is unspecified.

fromList :: ( Eq k, Hashable k) => [(k, a)] -> MonoidalHashMap k a Source #

O(n*log n) . Construct a map with the supplied mappings. If the list contains duplicate mappings, values will be replaced.

fromListWith :: ( Eq k, Hashable k) => (a -> a -> a) -> [(k, a)] -> MonoidalHashMap k a Source #

O(n*log n) . Construct a map with the supplied mappings. If the list contains duplicate mappings, values will be merged using the provided combining function.

singleton :: ( Eq k, Hashable k) => k -> a -> MonoidalHashMap k a Source #

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

size :: MonoidalHashMap k a -> Int Source #

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

member :: ( Eq k, Hashable k) => k -> MonoidalHashMap k a -> Bool Source #

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

notMember :: ( Eq k, Hashable k) => k -> MonoidalHashMap k a -> Bool Source #

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

lookup :: ( Eq k, Hashable k) => k -> MonoidalHashMap k v -> Maybe v Source #

O(log n) Return the value to which the specified key is mapped, or Nothing if this map contains no mapping for the key.

lookupM :: ( Eq k, Hashable k, Monoid v) => k -> MonoidalHashMap k v -> v Source #

O(log n) Return the value to which the specified key is mapped, or mempty if this map contains no mapping for the key.

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

O(n) . Return a list of this map's values. The list is produced lazily.

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

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

delete :: ( Eq k, Hashable k) => k -> MonoidalHashMap k a -> MonoidalHashMap k a Source #

O(log n) . Delete a key and its value from the map. When the key is not a member of the map, the original map is returned.

mapKeys :: ( Hashable k, Eq k, Hashable k', Eq k') => (k -> k') -> MonoidalHashMap k a -> MonoidalHashMap k' a Source #

O(n) . Map a function to each key of a map, if it will result in duplicated mappings, their values will be merged in unspecified order

insert :: ( Hashable k, Eq k) => k -> a -> MonoidalHashMap k a -> MonoidalHashMap k a Source #

O(log n) . Insert a value on some key, if it exists replace the value.

insertWith :: ( Hashable k, Eq k) => (a -> a -> a) -> k -> a -> MonoidalHashMap k a -> MonoidalHashMap k a Source #

O(log n) . Insert a value on some key, if it exists apply the combining function.

modify :: ( Monoid a, Hashable k, Eq k) => (a -> a) -> k -> MonoidalHashMap k a -> MonoidalHashMap k a Source #

O(log n) . Modify a value on some key with a function, if value under key doesn't exist -- use mempty.

modifyDef :: ( Hashable k, Eq k) => a -> (a -> a) -> k -> MonoidalHashMap k a -> MonoidalHashMap k a Source #

O(log n) . Modify a value on some key with a function, providing a default value if that key doesn't exist.

map :: (v1 -> v2) -> MonoidalHashMap k v1 -> MonoidalHashMap k v2 Source #

O(n) Transform this map by applying a function to every value.

filterWithKey :: (k -> v -> Bool ) -> MonoidalHashMap k v -> MonoidalHashMap k v Source #

O(n) Filter this map by retaining only elements satisfying a predicate.