Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Internal multimap module; standard disclaimers apply.
Synopsis
- newtype Multimap k c v = Multimap {
- getMultimap :: Map k (c v)
- null :: Multimap k c v -> Bool
- size :: Collection c => Multimap k c v -> Int
- empty :: Multimap k c v
- singleton :: (Collection c, Ord k) => k -> v -> Multimap k c v
- fromMap :: Collection c => Map k (c v) -> Multimap k c v
- fromList :: (Collection c, Semigroup (c v), Ord k) => [(k, v)] -> Multimap k c v
- fromCollectionsList :: (Collection c, Semigroup (c v), Ord k) => [(k, c v)] -> Multimap k c v
- member :: (Collection c, Ord k) => k -> Multimap k c v -> Bool
- notMember :: (Collection c, Ord k) => k -> Multimap k c v -> Bool
- (!) :: (Collection c, Ord k) => Multimap k c v -> k -> c v
- insert :: (Ord k, Collection c, Semigroup (c v)) => k -> v -> Multimap k c v -> Multimap k c v
- insertAll :: (Ord k, Semigroup (c v)) => k -> c v -> Multimap k c v -> Multimap k c v
- deleteAll :: Ord k => k -> Multimap k c v -> Multimap k c v
- filter :: (Collection c, Semigroup (c v), Ord k) => (v -> Bool) -> Multimap k c v -> Multimap k c v
- filterWithKey :: (Collection c, Semigroup (c v), Ord k) => (k -> v -> Bool) -> Multimap k c v -> Multimap k c v
- union :: (Ord k, Semigroup (c v)) => Multimap k c v -> Multimap k c v -> Multimap k c v
- toMap :: Multimap k c v -> Map k (c v)
- toMapWith :: (c v -> a) -> Multimap k c v -> Map k a
- toList :: Collection c => Multimap k c v -> [(k, v)]
- keys :: Multimap k c v -> [k]
- keysSet :: Multimap k c v -> Set k
- keysMultiset :: (Ord k, Collection c) => Multimap k c v -> Multiset k
- lift1 :: (Ord k, Collection c) => (c v -> c v) -> k -> Multimap k c v -> Multimap k c v
- liftF1 :: (Ord k, Collection c, Functor f) => (c v -> f (c v)) -> k -> Multimap k c v -> f (Multimap k c v)
Documentation
newtype Multimap k c v Source #
Multimap | |
|
Instances
Functor c => Functor (Multimap k c) Source # | |
Collection c => Foldable (Multimap k c) Source # | |
Defined in Data.Multimap.Internal fold :: Monoid m => Multimap k c m -> m # foldMap :: Monoid m => (a -> m) -> Multimap k c a -> m # foldr :: (a -> b -> b) -> b -> Multimap k c a -> b # foldr' :: (a -> b -> b) -> b -> Multimap k c a -> b # foldl :: (b -> a -> b) -> b -> Multimap k c a -> b # foldl' :: (b -> a -> b) -> b -> Multimap k c a -> b # foldr1 :: (a -> a -> a) -> Multimap k c a -> a # foldl1 :: (a -> a -> a) -> Multimap k c a -> a # toList :: Multimap k c a -> [a] # null :: Multimap k c a -> Bool # length :: Multimap k c a -> Int # elem :: Eq a => a -> Multimap k c a -> Bool # maximum :: Ord a => Multimap k c a -> a # minimum :: Ord a => Multimap k c a -> a # | |
(Eq k, Eq (c v)) => Eq (Multimap k c v) Source # | |
(Ord k, Ord (c v)) => Ord (Multimap k c v) Source # | |
Defined in Data.Multimap.Internal compare :: Multimap k c v -> Multimap k c v -> Ordering # (<) :: Multimap k c v -> Multimap k c v -> Bool # (<=) :: Multimap k c v -> Multimap k c v -> Bool # (>) :: Multimap k c v -> Multimap k c v -> Bool # (>=) :: Multimap k c v -> Multimap k c v -> Bool # | |
(Ord k, Read k, Read (c v)) => Read (Multimap k c v) Source # | |
(Show k, Show (c v)) => Show (Multimap k c v) Source # | |
(Ord k, Semigroup (c v)) => Semigroup (Multimap k c v) Source # | |
(Ord k, Semigroup (c v)) => Monoid (Multimap k c v) Source # | |
fromList :: (Collection c, Semigroup (c v), Ord k) => [(k, v)] -> Multimap k c v Source #
Build a multimap from a list.
This method uses insertWith
and semigroup's <>
operator. This might
not be what you want, for example in the case of lists (where the order of
the values will be inverted). For ordered collections, prefer
fromCollectionsList
.
fromCollectionsList :: (Collection c, Semigroup (c v), Ord k) => [(k, c v)] -> Multimap k c v Source #
Build a multimap from a list of key-collection pairs.
insert :: (Ord k, Collection c, Semigroup (c v)) => k -> v -> Multimap k c v -> Multimap k c v Source #
filter :: (Collection c, Semigroup (c v), Ord k) => (v -> Bool) -> Multimap k c v -> Multimap k c v Source #
filterWithKey :: (Collection c, Semigroup (c v), Ord k) => (k -> v -> Bool) -> Multimap k c v -> Multimap k c v Source #
toList :: Collection c => Multimap k c v -> [(k, v)] Source #
keysMultiset :: (Ord k, Collection c) => Multimap k c v -> Multiset k Source #
lift1 :: (Ord k, Collection c) => (c v -> c v) -> k -> Multimap k c v -> Multimap k c v Source #
Lift an operation over a collection of values into a multimap operation.
Sample use to filter even values from a SetMultimap
:
let ms = fromList [('a', 1), ('a', 2)] :: SetMultimap Char Int lift1 (Set.filter even) 'a' ms == fromList [('a', 1)]