Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
This module provides a IntMap
variant which uses the value's
Monoid
instance to accumulate conflicting entries when merging
Map
s.
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
- newtype MonoidalIntMap a = MonoidalIntMap {
- getMonoidalIntMap :: IntMap a
- singleton :: Int -> a -> MonoidalIntMap a
- size :: MonoidalIntMap a -> Int
- member :: Int -> MonoidalIntMap a -> Bool
- notMember :: Int -> MonoidalIntMap a -> Bool
- findWithDefault :: forall a. a -> Int -> MonoidalIntMap a -> a
- assocs :: MonoidalIntMap a -> [(Int, a)]
- elems :: MonoidalIntMap a -> [a]
- keys :: MonoidalIntMap a -> [Int]
- (!) :: forall a. MonoidalIntMap a -> Int -> a
- (\\) :: forall a b. MonoidalIntMap a -> MonoidalIntMap b -> MonoidalIntMap a
- adjust :: forall a. (a -> a) -> Int -> MonoidalIntMap a -> MonoidalIntMap a
- adjustWithKey :: forall a. (Int -> a -> a) -> Int -> MonoidalIntMap a -> MonoidalIntMap a
- alter :: forall a. (Maybe a -> Maybe a) -> Int -> MonoidalIntMap a -> MonoidalIntMap a
- delete :: Int -> MonoidalIntMap a -> MonoidalIntMap a
- deleteFindMax :: forall a. MonoidalIntMap a -> ((Int, a), MonoidalIntMap a)
- deleteFindMin :: forall a. MonoidalIntMap a -> ((Int, a), MonoidalIntMap a)
- deleteMax :: forall a. MonoidalIntMap a -> MonoidalIntMap a
- deleteMin :: forall a. MonoidalIntMap a -> MonoidalIntMap a
- difference :: forall a b. MonoidalIntMap a -> MonoidalIntMap b -> MonoidalIntMap a
- differenceWith :: forall a b. (a -> b -> Maybe a) -> MonoidalIntMap a -> MonoidalIntMap b -> MonoidalIntMap a
- differenceWithKey :: forall a b. (Int -> a -> b -> Maybe a) -> MonoidalIntMap a -> MonoidalIntMap b -> MonoidalIntMap a
- empty :: forall a. MonoidalIntMap a
- filter :: forall a. (a -> Bool) -> MonoidalIntMap a -> MonoidalIntMap a
- filterWithKey :: forall a. (Int -> a -> Bool) -> MonoidalIntMap a -> MonoidalIntMap a
- findMax :: forall a. MonoidalIntMap a -> (Int, a)
- findMin :: forall a. MonoidalIntMap a -> (Int, a)
- foldMapWithKey :: forall a m. Monoid m => (Int -> a -> m) -> MonoidalIntMap a -> m
- foldl :: forall a b. (a -> b -> a) -> a -> MonoidalIntMap b -> a
- foldl' :: forall a b. (a -> b -> a) -> a -> MonoidalIntMap b -> a
- foldlWithKey :: forall a b. (a -> Int -> b -> a) -> a -> MonoidalIntMap b -> a
- foldlWithKey' :: forall a b. (a -> Int -> b -> a) -> a -> MonoidalIntMap b -> a
- foldr :: forall a b. (a -> b -> b) -> b -> MonoidalIntMap a -> b
- foldr' :: forall a b. (a -> b -> b) -> b -> MonoidalIntMap a -> b
- foldrWithKey :: forall a b. (Int -> a -> b -> b) -> b -> MonoidalIntMap a -> b
- foldrWithKey' :: forall a b. (Int -> a -> b -> b) -> b -> MonoidalIntMap a -> b
- fromAscList :: forall a. [(Int, a)] -> MonoidalIntMap a
- fromAscListWith :: forall a. (a -> a -> a) -> [(Int, a)] -> MonoidalIntMap a
- fromAscListWithKey :: forall a. (Int -> a -> a -> a) -> [(Int, a)] -> MonoidalIntMap a
- fromDistinctAscList :: forall a. [(Int, a)] -> MonoidalIntMap a
- fromDistinctList :: forall a. [(Int, a)] -> MonoidalIntMap a
- fromList :: forall a. [(Int, a)] -> MonoidalIntMap a
- fromListWith :: forall a. (a -> a -> a) -> [(Int, a)] -> MonoidalIntMap a
- fromListWithKey :: forall a. (Int -> a -> a -> a) -> [(Int, a)] -> MonoidalIntMap a
- fromSet :: forall a. (Int -> a) -> IntSet -> MonoidalIntMap a
- insert :: forall a. Int -> a -> MonoidalIntMap a -> MonoidalIntMap a
- insertLookupWithKey :: forall a. (Int -> a -> a -> a) -> Int -> a -> MonoidalIntMap a -> (Maybe a, MonoidalIntMap a)
- insertWith :: forall a. (a -> a -> a) -> Int -> a -> MonoidalIntMap a -> MonoidalIntMap a
- insertWithKey :: forall a. (Int -> a -> a -> a) -> Int -> a -> MonoidalIntMap a -> MonoidalIntMap a
- intersectionWith :: forall a b c. (a -> b -> c) -> MonoidalIntMap a -> MonoidalIntMap b -> MonoidalIntMap c
- intersectionWithKey :: forall a b c. (Int -> a -> b -> c) -> MonoidalIntMap a -> MonoidalIntMap b -> MonoidalIntMap c
- isProperSubmapOf :: forall a. Eq a => MonoidalIntMap a -> MonoidalIntMap a -> Bool
- isProperSubmapOfBy :: forall a b. (a -> b -> Bool) -> MonoidalIntMap a -> MonoidalIntMap b -> Bool
- isSubmapOf :: forall a. Eq a => MonoidalIntMap a -> MonoidalIntMap a -> Bool
- isSubmapOfBy :: forall a b. (a -> b -> Bool) -> MonoidalIntMap a -> MonoidalIntMap b -> Bool
- keysSet :: forall a. MonoidalIntMap a -> IntSet
- lookup :: forall a. Int -> MonoidalIntMap a -> Maybe a
- lookupGE :: forall a. Int -> MonoidalIntMap a -> Maybe (Int, a)
- lookupGT :: forall a. Int -> MonoidalIntMap a -> Maybe (Int, a)
- lookupLE :: forall a. Int -> MonoidalIntMap a -> Maybe (Int, a)
- lookupLT :: forall a. Int -> MonoidalIntMap a -> Maybe (Int, a)
- map :: (a -> b) -> MonoidalIntMap a -> MonoidalIntMap b
- mapAccum :: forall a b c. (a -> b -> (a, c)) -> a -> MonoidalIntMap b -> (a, MonoidalIntMap c)
- mapAccumRWithKey :: forall a b c. (a -> Int -> b -> (a, c)) -> a -> MonoidalIntMap b -> (a, MonoidalIntMap c)
- mapAccumWithKey :: forall a b c. (a -> Int -> b -> (a, c)) -> a -> MonoidalIntMap b -> (a, MonoidalIntMap c)
- mapEither :: forall a b c. (a -> Either b c) -> MonoidalIntMap a -> (MonoidalIntMap b, MonoidalIntMap c)
- mapEitherWithKey :: forall a b c. (Int -> a -> Either b c) -> MonoidalIntMap a -> (MonoidalIntMap b, MonoidalIntMap c)
- mapKeys :: forall a. (Int -> Int) -> MonoidalIntMap a -> MonoidalIntMap a
- mapKeysMonotonic :: forall a. (Int -> Int) -> MonoidalIntMap a -> MonoidalIntMap a
- mapKeysWith :: forall a. (a -> a -> a) -> (Int -> Int) -> MonoidalIntMap a -> MonoidalIntMap a
- mapMaybe :: forall a b. (a -> Maybe b) -> MonoidalIntMap a -> MonoidalIntMap b
- mapMaybeWithKey :: forall a b. (Int -> a -> Maybe b) -> MonoidalIntMap a -> MonoidalIntMap b
- mapWithKey :: forall a b. (Int -> a -> b) -> MonoidalIntMap a -> MonoidalIntMap b
- maxView :: forall a. MonoidalIntMap a -> Maybe (a, MonoidalIntMap a)
- maxViewWithKey :: forall a. MonoidalIntMap a -> Maybe ((Int, a), MonoidalIntMap a)
- mergeWithKey :: forall a b c. (Int -> a -> b -> Maybe c) -> (MonoidalIntMap a -> MonoidalIntMap c) -> (MonoidalIntMap b -> MonoidalIntMap c) -> MonoidalIntMap a -> MonoidalIntMap b -> MonoidalIntMap c
- minView :: forall a. MonoidalIntMap a -> Maybe (a, MonoidalIntMap a)
- minViewWithKey :: forall a. MonoidalIntMap a -> Maybe ((Int, a), MonoidalIntMap a)
- null :: forall a. MonoidalIntMap a -> Bool
- partition :: forall a. (a -> Bool) -> MonoidalIntMap a -> (MonoidalIntMap a, MonoidalIntMap a)
- partitionWithKey :: forall a. (Int -> a -> Bool) -> MonoidalIntMap a -> (MonoidalIntMap a, MonoidalIntMap a)
- split :: forall a. Int -> MonoidalIntMap a -> (MonoidalIntMap a, MonoidalIntMap a)
- splitLookup :: forall a. Int -> MonoidalIntMap a -> (MonoidalIntMap a, Maybe a, MonoidalIntMap a)
- splitRoot :: forall a. MonoidalIntMap a -> [MonoidalIntMap a]
- toAscList :: forall a. MonoidalIntMap a -> [(Int, a)]
- toDescList :: forall a. MonoidalIntMap a -> [(Int, a)]
- toList :: forall a. MonoidalIntMap a -> [(Int, a)]
- traverseWithKey :: Applicative t => (Int -> a -> t b) -> MonoidalIntMap a -> t (MonoidalIntMap b)
- unionWith :: forall a. (a -> a -> a) -> MonoidalIntMap a -> MonoidalIntMap a -> MonoidalIntMap a
- unionWithKey :: forall a. (Int -> a -> a -> a) -> MonoidalIntMap a -> MonoidalIntMap a -> MonoidalIntMap a
- unionsWith :: forall a. (a -> a -> a) -> [MonoidalIntMap a] -> MonoidalIntMap a
- update :: forall a. (a -> Maybe a) -> Int -> MonoidalIntMap a -> MonoidalIntMap a
- updateLookupWithKey :: forall a. (Int -> a -> Maybe a) -> Int -> MonoidalIntMap a -> (Maybe a, MonoidalIntMap a)
- updateMax :: forall a. (a -> Maybe a) -> MonoidalIntMap a -> MonoidalIntMap a
- updateMaxWithKey :: forall a. (Int -> a -> Maybe a) -> MonoidalIntMap a -> MonoidalIntMap a
- updateMin :: forall a. (a -> Maybe a) -> MonoidalIntMap a -> MonoidalIntMap a
- updateMinWithKey :: forall a. (Int -> a -> Maybe a) -> MonoidalIntMap a -> MonoidalIntMap a
- updateWithKey :: forall a. (Int -> a -> Maybe a) -> Int -> MonoidalIntMap a -> MonoidalIntMap a
Documentation
newtype MonoidalIntMap a Source #
An IntMap
with monoidal accumulation
Instances
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 (
returns
the value at key findWithDefault
def k map)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.
deleteFindMax :: forall a. MonoidalIntMap a -> ((Int, a), MonoidalIntMap a) Source #
deleteFindMin :: forall a. MonoidalIntMap a -> ((Int, a), MonoidalIntMap a) Source #
deleteMax :: forall a. MonoidalIntMap a -> MonoidalIntMap a Source #
deleteMin :: forall a. MonoidalIntMap a -> MonoidalIntMap a Source #
difference :: forall a b. MonoidalIntMap a -> MonoidalIntMap b -> MonoidalIntMap a Source #
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 #
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 #
isProperSubmapOf :: forall a. Eq a => MonoidalIntMap a -> MonoidalIntMap a -> Bool 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 #
keysSet :: forall a. MonoidalIntMap a -> IntSet 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 #
mapKeysMonotonic :: 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 #
maxView :: forall a. MonoidalIntMap a -> Maybe (a, MonoidalIntMap a) Source #
maxViewWithKey :: forall a. MonoidalIntMap a -> Maybe ((Int, a), MonoidalIntMap a) 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 #
minView :: forall a. MonoidalIntMap a -> Maybe (a, MonoidalIntMap a) Source #
minViewWithKey :: forall a. MonoidalIntMap a -> Maybe ((Int, a), MonoidalIntMap a) Source #
null :: forall a. MonoidalIntMap a -> Bool Source #
partition :: forall a. (a -> Bool) -> MonoidalIntMap a -> (MonoidalIntMap a, MonoidalIntMap a) Source #
partitionWithKey :: forall a. (Int -> a -> Bool) -> MonoidalIntMap a -> (MonoidalIntMap a, MonoidalIntMap a) Source #
split :: forall a. Int -> MonoidalIntMap a -> (MonoidalIntMap a, MonoidalIntMap a) Source #
splitLookup :: forall a. Int -> MonoidalIntMap a -> (MonoidalIntMap a, Maybe a, MonoidalIntMap a) Source #
splitRoot :: forall a. MonoidalIntMap a -> [MonoidalIntMap a] 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 #
traverseWithKey :: Applicative t => (Int -> a -> t b) -> MonoidalIntMap a -> t (MonoidalIntMap b) 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 #