monoidal-containers-0.6.4.0: Containers with monoidal accumulation
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.IntMap.Monoidal

Description

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

While some functions mirroring those of IntMap 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 MonoidalIntMap a Source #

An IntMap with monoidal accumulation

Constructors

MonoidalIntMap 

Instances

Instances details
FromJSON1 MonoidalIntMap Source # 
Instance details

Defined in Data.IntMap.Monoidal

Methods

liftParseJSON :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser (MonoidalIntMap a) #

liftParseJSONList :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser [MonoidalIntMap a] #

ToJSON1 MonoidalIntMap Source # 
Instance details

Defined in Data.IntMap.Monoidal

Methods

liftToJSON :: (a -> Value) -> ([a] -> Value) -> MonoidalIntMap a -> Value #

liftToJSONList :: (a -> Value) -> ([a] -> Value) -> [MonoidalIntMap a] -> Value #

liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> MonoidalIntMap a -> Encoding #

liftToEncodingList :: (a -> Encoding) -> ([a] -> Encoding) -> [MonoidalIntMap a] -> Encoding #

Foldable MonoidalIntMap Source # 
Instance details

Defined in Data.IntMap.Monoidal

Methods

fold :: Monoid m => MonoidalIntMap m -> m #

foldMap :: Monoid m => (a -> m) -> MonoidalIntMap a -> m #

foldMap' :: Monoid m => (a -> m) -> MonoidalIntMap a -> m #

foldr :: (a -> b -> b) -> b -> MonoidalIntMap a -> b #

foldr' :: (a -> b -> b) -> b -> MonoidalIntMap a -> b #

foldl :: (b -> a -> b) -> b -> MonoidalIntMap a -> b #

foldl' :: (b -> a -> b) -> b -> MonoidalIntMap a -> b #

foldr1 :: (a -> a -> a) -> MonoidalIntMap a -> a #

foldl1 :: (a -> a -> a) -> MonoidalIntMap a -> a #

toList :: MonoidalIntMap a -> [a] #

null :: MonoidalIntMap a -> Bool #

length :: MonoidalIntMap a -> Int #

elem :: Eq a => a -> MonoidalIntMap a -> Bool #

maximum :: Ord a => MonoidalIntMap a -> a #

minimum :: Ord a => MonoidalIntMap a -> a #

sum :: Num a => MonoidalIntMap a -> a #

product :: Num a => MonoidalIntMap a -> a #

Eq1 MonoidalIntMap Source # 
Instance details

Defined in Data.IntMap.Monoidal

Methods

liftEq :: (a -> b -> Bool) -> MonoidalIntMap a -> MonoidalIntMap b -> Bool #

Ord1 MonoidalIntMap Source # 
Instance details

Defined in Data.IntMap.Monoidal

Methods

liftCompare :: (a -> b -> Ordering) -> MonoidalIntMap a -> MonoidalIntMap b -> Ordering #

Show1 MonoidalIntMap Source # 
Instance details

Defined in Data.IntMap.Monoidal

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> MonoidalIntMap a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [MonoidalIntMap a] -> ShowS #

Traversable MonoidalIntMap Source # 
Instance details

Defined in Data.IntMap.Monoidal

Methods

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

sequenceA :: Applicative f => MonoidalIntMap (f a) -> f (MonoidalIntMap a) #

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

sequence :: Monad m => MonoidalIntMap (m a) -> m (MonoidalIntMap a) #

Functor MonoidalIntMap Source # 
Instance details

Defined in Data.IntMap.Monoidal

Methods

fmap :: (a -> b) -> MonoidalIntMap a -> MonoidalIntMap b #

(<$) :: a -> MonoidalIntMap b -> MonoidalIntMap a #

Align MonoidalIntMap Source # 
Instance details

Defined in Data.IntMap.Monoidal

Methods

nil :: MonoidalIntMap a #

Semialign MonoidalIntMap Source # 
Instance details

Defined in Data.IntMap.Monoidal

Unalign MonoidalIntMap Source # 
Instance details

Defined in Data.IntMap.Monoidal

Zip MonoidalIntMap Source # 
Instance details

Defined in Data.IntMap.Monoidal

Methods

zip :: MonoidalIntMap a -> MonoidalIntMap b -> MonoidalIntMap (a, b) #

zipWith :: (a -> b -> c) -> MonoidalIntMap a -> MonoidalIntMap b -> MonoidalIntMap c #

Filterable MonoidalIntMap Source # 
Instance details

Defined in Data.IntMap.Monoidal

Witherable MonoidalIntMap Source # 
Instance details

Defined in Data.IntMap.Monoidal

Methods

wither :: Applicative f => (a -> f (Maybe b)) -> MonoidalIntMap a -> f (MonoidalIntMap b) #

witherM :: Monad m => (a -> m (Maybe b)) -> MonoidalIntMap a -> m (MonoidalIntMap b) #

filterA :: Applicative f => (a -> f Bool) -> MonoidalIntMap a -> f (MonoidalIntMap a) #

witherMap :: Applicative m => (MonoidalIntMap b -> r) -> (a -> m (Maybe b)) -> MonoidalIntMap a -> m r #

FoldableWithIndex Int MonoidalIntMap Source # 
Instance details

Defined in Data.IntMap.Monoidal

Methods

ifoldMap :: Monoid m => (Int -> a -> m) -> MonoidalIntMap a -> m #

ifoldMap' :: Monoid m => (Int -> a -> m) -> MonoidalIntMap a -> m #

ifoldr :: (Int -> a -> b -> b) -> b -> MonoidalIntMap a -> b #

ifoldl :: (Int -> b -> a -> b) -> b -> MonoidalIntMap a -> b #

ifoldr' :: (Int -> a -> b -> b) -> b -> MonoidalIntMap a -> b #

ifoldl' :: (Int -> b -> a -> b) -> b -> MonoidalIntMap a -> b #

FunctorWithIndex Int MonoidalIntMap Source # 
Instance details

Defined in Data.IntMap.Monoidal

Methods

imap :: (Int -> a -> b) -> MonoidalIntMap a -> MonoidalIntMap b #

TraversableWithIndex Int MonoidalIntMap Source # 
Instance details

Defined in Data.IntMap.Monoidal

Methods

itraverse :: Applicative f => (Int -> a -> f b) -> MonoidalIntMap a -> f (MonoidalIntMap b) #

TraverseMax Int MonoidalIntMap Source # 
Instance details

Defined in Data.IntMap.Monoidal

TraverseMin Int MonoidalIntMap Source # 
Instance details

Defined in Data.IntMap.Monoidal

FromJSON a => FromJSON (MonoidalIntMap a) Source # 
Instance details

Defined in Data.IntMap.Monoidal

ToJSON a => ToJSON (MonoidalIntMap a) Source # 
Instance details

Defined in Data.IntMap.Monoidal

Data a => Data (MonoidalIntMap a) Source # 
Instance details

Defined in Data.IntMap.Monoidal

Methods

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

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

toConstr :: MonoidalIntMap a -> Constr #

dataTypeOf :: MonoidalIntMap a -> DataType #

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

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

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

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

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

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

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

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

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

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

Semigroup a => Monoid (MonoidalIntMap a) Source # 
Instance details

Defined in Data.IntMap.Monoidal

Semigroup a => Semigroup (MonoidalIntMap a) Source # 
Instance details

Defined in Data.IntMap.Monoidal

Semigroup a => IsList (MonoidalIntMap a) Source # 
Instance details

Defined in Data.IntMap.Monoidal

Associated Types

type Item (MonoidalIntMap a) #

Read a => Read (MonoidalIntMap a) Source # 
Instance details

Defined in Data.IntMap.Monoidal

Show a => Show (MonoidalIntMap a) Source # 
Instance details

Defined in Data.IntMap.Monoidal

NFData a => NFData (MonoidalIntMap a) Source # 
Instance details

Defined in Data.IntMap.Monoidal

Methods

rnf :: MonoidalIntMap a -> () #

Eq a => Eq (MonoidalIntMap a) Source # 
Instance details

Defined in Data.IntMap.Monoidal

Ord a => Ord (MonoidalIntMap a) Source # 
Instance details

Defined in Data.IntMap.Monoidal

At (MonoidalIntMap a) Source # 
Instance details

Defined in Data.IntMap.Monoidal

Ixed (MonoidalIntMap a) Source # 
Instance details

Defined in Data.IntMap.Monoidal

AsEmpty (MonoidalIntMap a) Source # 
Instance details

Defined in Data.IntMap.Monoidal

Methods

_Empty :: Prism' (MonoidalIntMap a) () #

Wrapped (MonoidalIntMap a) Source # 
Instance details

Defined in Data.IntMap.Monoidal

Associated Types

type Unwrapped (MonoidalIntMap a) #

Newtype (MonoidalIntMap a) (IntMap a) Source # 
Instance details

Defined in Data.IntMap.Monoidal

Each (MonoidalIntMap a) (MonoidalIntMap b) a b Source # 
Instance details

Defined in Data.IntMap.Monoidal

type Item (MonoidalIntMap a) Source # 
Instance details

Defined in Data.IntMap.Monoidal

type Item (MonoidalIntMap a) = (Int, a)
type Index (MonoidalIntMap a) Source # 
Instance details

Defined in Data.IntMap.Monoidal

type IxValue (MonoidalIntMap a) Source # 
Instance details

Defined in Data.IntMap.Monoidal

type IxValue (MonoidalIntMap a) = a
type Unwrapped (MonoidalIntMap a) Source # 
Instance details

Defined in Data.IntMap.Monoidal

Often-needed functions

singleton :: Int -> a -> MonoidalIntMap a Source #

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

size :: MonoidalIntMap a -> Int Source #

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

member :: Int -> MonoidalIntMap a -> Bool Source #

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

notMember :: Int -> MonoidalIntMap a -> Bool Source #

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

findWithDefault :: forall a. a -> Int -> MonoidalIntMap 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 :: MonoidalIntMap a -> [(Int, a)] Source #

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

elems :: MonoidalIntMap a -> [a] Source #

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

keys :: MonoidalIntMap a -> [Int] Source #

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

(!) :: forall a. MonoidalIntMap a -> Int -> a infixl 9 Source #

(\\) :: forall a b. MonoidalIntMap a -> MonoidalIntMap b -> MonoidalIntMap a infixl 9 Source #

adjust :: forall a. (a -> a) -> Int -> MonoidalIntMap a -> MonoidalIntMap a Source #

adjustWithKey :: forall a. (Int -> a -> a) -> Int -> MonoidalIntMap a -> MonoidalIntMap a Source #

alter :: forall a. (Maybe a -> Maybe a) -> Int -> MonoidalIntMap a -> MonoidalIntMap a Source #

delete :: Int -> MonoidalIntMap a -> MonoidalIntMap 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.

differenceWith :: forall a b. (a -> b -> Maybe a) -> MonoidalIntMap a -> MonoidalIntMap b -> MonoidalIntMap a Source #

differenceWithKey :: forall a b. (Int -> a -> b -> Maybe a) -> MonoidalIntMap a -> MonoidalIntMap b -> MonoidalIntMap a Source #

empty :: forall a. MonoidalIntMap a Source #

filter :: forall a. (a -> Bool) -> MonoidalIntMap a -> MonoidalIntMap a Source #

filterWithKey :: forall a. (Int -> a -> Bool) -> MonoidalIntMap a -> MonoidalIntMap a Source #

findMax :: forall a. MonoidalIntMap a -> (Int, a) Source #

findMin :: forall a. MonoidalIntMap a -> (Int, a) Source #

foldMapWithKey :: forall a m. Monoid m => (Int -> a -> m) -> MonoidalIntMap a -> m Source #

foldl :: forall a b. (a -> b -> a) -> a -> MonoidalIntMap b -> a Source #

foldl' :: forall a b. (a -> b -> a) -> a -> MonoidalIntMap b -> a Source #

foldlWithKey :: forall a b. (a -> Int -> b -> a) -> a -> MonoidalIntMap b -> a Source #

foldlWithKey' :: forall a b. (a -> Int -> b -> a) -> a -> MonoidalIntMap b -> a Source #

foldr :: forall a b. (a -> b -> b) -> b -> MonoidalIntMap a -> b Source #

foldr' :: forall a b. (a -> b -> b) -> b -> MonoidalIntMap a -> b Source #

foldrWithKey :: forall a b. (Int -> a -> b -> b) -> b -> MonoidalIntMap a -> b Source #

foldrWithKey' :: forall a b. (Int -> a -> b -> b) -> b -> MonoidalIntMap a -> b Source #

fromAscList :: forall a. [(Int, a)] -> MonoidalIntMap a Source #

fromAscListWith :: forall a. (a -> a -> a) -> [(Int, a)] -> MonoidalIntMap a Source #

fromAscListWithKey :: forall a. (Int -> a -> a -> a) -> [(Int, a)] -> MonoidalIntMap a Source #

fromDistinctAscList :: forall a. [(Int, a)] -> MonoidalIntMap a Source #

fromDistinctList :: forall a. [(Int, a)] -> MonoidalIntMap a Source #

fromList :: forall a. [(Int, a)] -> MonoidalIntMap a Source #

fromListWith :: forall a. (a -> a -> a) -> [(Int, a)] -> MonoidalIntMap a Source #

fromListWithKey :: forall a. (Int -> a -> a -> a) -> [(Int, a)] -> MonoidalIntMap a Source #

fromSet :: forall a. (Int -> a) -> IntSet -> MonoidalIntMap a Source #

insert :: forall a. Int -> a -> MonoidalIntMap a -> MonoidalIntMap a Source #

insertLookupWithKey :: forall a. (Int -> a -> a -> a) -> Int -> a -> MonoidalIntMap a -> (Maybe a, MonoidalIntMap a) Source #

insertWith :: forall a. (a -> a -> a) -> Int -> a -> MonoidalIntMap a -> MonoidalIntMap a Source #

insertWithKey :: forall a. (Int -> a -> a -> a) -> Int -> a -> MonoidalIntMap a -> MonoidalIntMap a Source #

intersectionWith :: forall a b c. (a -> b -> c) -> MonoidalIntMap a -> MonoidalIntMap b -> MonoidalIntMap c Source #

intersectionWithKey :: forall a b c. (Int -> a -> b -> c) -> MonoidalIntMap a -> MonoidalIntMap b -> MonoidalIntMap c Source #

isProperSubmapOfBy :: forall a b. (a -> b -> Bool) -> MonoidalIntMap a -> MonoidalIntMap b -> Bool Source #

isSubmapOf :: forall a. Eq a => MonoidalIntMap a -> MonoidalIntMap a -> Bool Source #

isSubmapOfBy :: forall a b. (a -> b -> Bool) -> MonoidalIntMap a -> MonoidalIntMap b -> Bool Source #

lookup :: forall a. Int -> MonoidalIntMap a -> Maybe a Source #

lookupGE :: forall a. Int -> MonoidalIntMap a -> Maybe (Int, a) Source #

lookupGT :: forall a. Int -> MonoidalIntMap a -> Maybe (Int, a) Source #

lookupLE :: forall a. Int -> MonoidalIntMap a -> Maybe (Int, a) Source #

lookupLT :: forall a. Int -> MonoidalIntMap a -> Maybe (Int, a) Source #

map :: (a -> b) -> MonoidalIntMap a -> MonoidalIntMap b Source #

mapAccum :: forall a b c. (a -> b -> (a, c)) -> a -> MonoidalIntMap b -> (a, MonoidalIntMap c) Source #

mapAccumRWithKey :: forall a b c. (a -> Int -> b -> (a, c)) -> a -> MonoidalIntMap b -> (a, MonoidalIntMap c) Source #

mapAccumWithKey :: forall a b c. (a -> Int -> b -> (a, c)) -> a -> MonoidalIntMap b -> (a, MonoidalIntMap c) Source #

mapEither :: forall a b c. (a -> Either b c) -> MonoidalIntMap a -> (MonoidalIntMap b, MonoidalIntMap c) Source #

mapEitherWithKey :: forall a b c. (Int -> a -> Either b c) -> MonoidalIntMap a -> (MonoidalIntMap b, MonoidalIntMap c) Source #

mapKeys :: forall a. (Int -> Int) -> MonoidalIntMap a -> MonoidalIntMap a Source #

mapKeysWith :: forall a. (a -> a -> a) -> (Int -> Int) -> MonoidalIntMap a -> MonoidalIntMap a Source #

mapMaybe :: forall a b. (a -> Maybe b) -> MonoidalIntMap a -> MonoidalIntMap b Source #

mapMaybeWithKey :: forall a b. (Int -> a -> Maybe b) -> MonoidalIntMap a -> MonoidalIntMap b Source #

mapWithKey :: forall a b. (Int -> a -> b) -> MonoidalIntMap a -> MonoidalIntMap b Source #

mergeWithKey :: forall a b c. (Int -> a -> b -> Maybe c) -> (MonoidalIntMap a -> MonoidalIntMap c) -> (MonoidalIntMap b -> MonoidalIntMap c) -> MonoidalIntMap a -> MonoidalIntMap b -> MonoidalIntMap c Source #

null :: forall a. MonoidalIntMap a -> Bool Source #

toAscList :: forall a. MonoidalIntMap a -> [(Int, a)] Source #

toDescList :: forall a. MonoidalIntMap a -> [(Int, a)] Source #

toList :: forall a. MonoidalIntMap a -> [(Int, a)] Source #

unionWith :: forall a. (a -> a -> a) -> MonoidalIntMap a -> MonoidalIntMap a -> MonoidalIntMap a Source #

unionWithKey :: forall a. (Int -> a -> a -> a) -> MonoidalIntMap a -> MonoidalIntMap a -> MonoidalIntMap a Source #

unionsWith :: forall a. (a -> a -> a) -> [MonoidalIntMap a] -> MonoidalIntMap a Source #

update :: forall a. (a -> Maybe a) -> Int -> MonoidalIntMap a -> MonoidalIntMap a Source #

updateLookupWithKey :: forall a. (Int -> a -> Maybe a) -> Int -> MonoidalIntMap a -> (Maybe a, MonoidalIntMap a) Source #

updateMax :: forall a. (a -> Maybe a) -> MonoidalIntMap a -> MonoidalIntMap a Source #

updateMaxWithKey :: forall a. (Int -> a -> Maybe a) -> MonoidalIntMap a -> MonoidalIntMap a Source #

updateMin :: forall a. (a -> Maybe a) -> MonoidalIntMap a -> MonoidalIntMap a Source #

updateMinWithKey :: forall a. (Int -> a -> Maybe a) -> MonoidalIntMap a -> MonoidalIntMap a Source #

updateWithKey :: forall a. (Int -> a -> Maybe a) -> Int -> MonoidalIntMap a -> MonoidalIntMap a Source #