-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Class of key-value maps -- -- Class of key-value maps @package Map @version 0.1.3.3 -- | Class of key-value maps -- -- See StaticMap and Map. module Data.Map.Class -- | Class of key-value maps -- -- Laws: -- -- class Traversable map => StaticMap map where { type family Key map; } -- | Modify the value of the key in the map. If the key is absent, the map -- is returned unmodified. adjustA :: (StaticMap map, Applicative p) => (a -> p a) -> Key map -> map a -> p (map a) -- | Traverse a function over each value in the map. traverseWithKey :: (StaticMap map, Applicative p) => (Key map -> a -> p b) -> map a -> p (map b) -- | Class of key-value maps with variable structure class (Filtrable map, StaticMap map) => Map map -- | The empty map empty :: Map map => map a -- | Modify the value of the key in the map, or insert the key and its -- value into the map, or delete the key and its value from the map, -- functorially. -- --
--   fmap (!? k) . alterF f k = f . (!? k)
--   
-- -- This is the most general operation on a given key in the map. alterF :: (Map map, Functor f) => (Maybe a -> f (Maybe a)) -> Key map -> map a -> f (map a) -- | Combine two maps with the given function, which is called once for -- each key present in either map, inclusive. mergeA :: (Map map, Applicative p) => (Key map -> Either' a b -> p (Maybe c)) -> map a -> map b -> p (map c) -- | Traverse a function over each value in the map, gathering the -- Just values and forgetting the Nothing. mapMaybeWithKeyA :: (Map map, Applicative p) => (Key map -> a -> p (Maybe b)) -> map a -> p (map b) -- | Traverse a function over each value in the map, gathering the -- Left and Right values separately. mapEitherWithKeyA :: (Map map, Applicative p) => (Key map -> a -> p (Either b c)) -> map a -> p (map b, map c) -- | Default implementation of adjustA in terms of Map -- methods defaultAdjustA :: (Map map, Applicative p) => (a -> p a) -> Key map -> map a -> p (map a) -- | Default implementation of traverseWithKey in terms of -- Map methods defaultTraverseWithKey :: (Map map, Applicative p) => (Key map -> a -> p b) -> map a -> p (map b) -- | Look up the key in the map. (!?) :: StaticMap map => map a -> Key map -> Maybe a infix 9 !? -- | Insert a key and new value into the map, the new value clobbering the -- old if the key is already present. insert = -- insertWith pure insert :: Map map => Key map -> a -> map a -> map a -- | Insert a key and new value into the map, combining the old and new -- values with the given function if the key is already present. insertWith :: Map map => (a -> a -> a) -> Key map -> a -> map a -> map a -- | Insert a key and new value into the map, looking up the old value if -- the key is already present. insertLookup :: Map map => Key map -> a -> map a -> (Maybe a, map a) -- | Insert a key and new value into the map, looking up the old value and -- combining the old and new values with the given function if the key is -- already present. insertLookupWith :: Map map => (a -> a -> a) -> Key map -> a -> map a -> (Maybe a, map a) -- | Delete a key and its value from the map. If the key is absent, the map -- is returned unmodified. delete :: Map map => Key map -> map a -> map a -- | Modify the value of the key in the map. If the key is absent, the map -- is returned unmodified. adjust :: StaticMap map => (a -> a) -> Key map -> map a -> map a -- | Modify the value of the key in the map, or delete the key and its -- value from the map, if the given function returns Just or -- Nothing, in turn. If the key is absent, the map is returned -- unmodified. update :: Map map => (a -> Maybe a) -> Key map -> map a -> map a -- | Modify the value of the key in the map, or delete the key and its -- value from the map, if the given function returns Just or -- Nothing, in turn, looking up the old value if the key is -- already present. If the key is absent, the map is returned unmodified. updateLookup :: Map map => (a -> Maybe a) -> Key map -> map a -> (Maybe a, map a) -- | Modify the value of the key in the map, or insert the key and its -- value into the map, or delete the key and its value from the map. alter :: Map map => (Maybe a -> Maybe a) -> Key map -> map a -> map a -- | Modify the value of the key in the map, or insert the key and its -- value into the map, or delete the key and its value from the map, -- looking up the old value if the key is already present. alterLookup :: Map map => (Maybe a -> Maybe a) -> Key map -> map a -> (Maybe a, map a) -- | Modify the value of the key in the map, or insert the key and its -- value into the map, or delete the key and its value from the map, -- looking up the old value if the key is already present, functorially. -- -- This is no more general than alterF, but is defined for -- convenience. alterLookupF :: (Map map, Functor f) => (Maybe a -> f (Maybe a)) -> Key map -> map a -> f (Maybe a, map a) -- | Map a function over each value in the map. mapWithKey :: StaticMap map => (Key map -> a -> b) -> map a -> map b -- | Map a function over each value in the map, gathering the Just -- values and forgetting the Nothing. mapMaybeWithKey :: Map map => (Key map -> a -> Maybe b) -> map a -> map b -- | Map a function over each value in the map, gathering the Left -- and Right separately. mapEitherWithKey :: Map map => (Key map -> a -> Either b c) -> map a -> (map b, map c) foldMapWithKeyA :: (StaticMap map, Applicative p, Monoid b) => (Key map -> a -> p b) -> map a -> p b foldrWithKeyM :: (StaticMap map, Monad m) => (Key map -> a -> b -> m b) -> b -> map a -> m b foldlWithKeyM :: (StaticMap map, Monad m) => (b -> Key map -> a -> m b) -> b -> map a -> m b foldMapWithKey :: (StaticMap map, Monoid b) => (Key map -> a -> b) -> map a -> b foldrWithKey :: StaticMap map => (Key map -> a -> b -> b) -> b -> map a -> b foldlWithKey :: StaticMap map => (b -> Key map -> a -> b) -> b -> map a -> b fromList :: Map map => [(Key map, a)] -> map a fromListWith :: Map map => (a -> a -> a) -> [(Key map, a)] -> map a fromListWithKey :: Map map => (Key map -> a -> a -> a) -> [(Key map, a)] -> map a fromListWithM :: (Map map, Monad m) => (a -> a -> m a) -> [(Key map, a)] -> m (map a) fromListWithKeyM :: (Map map, Monad m) => (Key map -> a -> a -> m a) -> [(Key map, a)] -> m (map a) -- | Modify the value of the key in the map, looking up the old value if -- the key is already present. If the key is absent, the map is returned -- unmodified. adjustLookupA :: (StaticMap map, Applicative p) => (a -> p a) -> Key map -> map a -> p (Maybe a, map a) -- | Map with a single element singleton :: Map map => Key map -> a -> map a -- | Union of two maps, combining values of the same key with the given -- function unionWith :: Map map => (Key map -> a -> a -> a) -> map a -> map a -> map a -- | Intersection of two maps, combining values of the same key with the -- given function intersectionWith :: Map map => (Key map -> a -> b -> c) -> map a -> map b -> map c -- | Combine two maps with the given function, which is called once for -- each key present in either map, inclusive. merge :: Map map => (Key map -> Either' a b -> Maybe c) -> map a -> map b -> map c -- | Union of two maps, combining values of the same key with the given -- function unionWithA :: (Map map, Applicative p) => (Key map -> a -> a -> p a) -> map a -> map a -> p (map a) -- | Intersection of two maps, combining values of the same key with the -- given function intersectionWithA :: (Map map, Applicative p) => (Key map -> a -> b -> p c) -> map a -> map b -> p (map c) -- | Difference of two maps, which contains exactly the keys present in the -- first map but absent in the second difference :: Map map => map a -> map b -> map a -- | Symmetric difference of two maps, which contains exactly the keys -- present in the either map but absent in the other symmetricDifference :: Map map => map a -> map a -> map a -- | Map a function over each key in the map. mapKeys :: (StaticMap m, Map n) => (Key m -> Key n) -> m a -> n a -- | Map a function over each key in the map, combining values of keys -- which collide with the given function. mapKeysWith :: (StaticMap m, Map n) => (a -> a -> a) -> (Key m -> Key n) -> m a -> n a -- | Traverse a function over each key in the map. traverseKeys :: (StaticMap m, Map n, Applicative p) => (Key m -> p (Key n)) -> m a -> p (n a) -- | Traverse a function over each key in the map, combining values of keys -- which collide with the given function. traverseKeysWith :: (StaticMap m, Map n, Applicative p) => (a -> a -> a) -> (Key m -> p (Key n)) -> m a -> p (n a) -- | Map a function over each key in the map, gathering the Just -- values and forgetting the Nothing. mapKeysMaybe :: (StaticMap m, Map n) => (Key m -> Maybe (Key n)) -> m a -> n a -- | Map a function over each key in the map, gathering the Just -- values and forgetting the Nothing, combining values of keys -- which collide with the given function. mapKeysMaybeWith :: (StaticMap m, Map n) => (a -> a -> a) -> (Key m -> Maybe (Key n)) -> m a -> n a -- | Traverse a function over each key in the map, gathering the -- Just values and forgetting the Nothing. traverseKeysMaybe :: (StaticMap m, Map n, Applicative p) => (Key m -> p (Maybe (Key n))) -> m a -> p (n a) -- | Traverse a function over each key in the map, gathering the -- Just values and forgetting the Nothing, combining values -- of keys which collide with the given function. traverseKeysMaybeWith :: (StaticMap m, Map n, Applicative p) => (a -> a -> a) -> (Key m -> p (Maybe (Key n))) -> m a -> p (n a) -- | Keys of the map -- --
--   keys as !? k = k <$ (as !? k)
--   
keys :: StaticMap map => map a -> map (Key map) -- | Wrapper of a Map whose semigroup operation is the union, -- combining values elementwise, and ergo whose monoidal unit is empty newtype Union map a Union :: map a -> Union map a [unUnion] :: Union map a -> map a -- | Wrapper of a Map whose semigroup operation is the intersection, -- combining values elementwise newtype Intersection map a Intersection :: map a -> Intersection map a [unIntersection] :: Intersection map a -> map a -- | Wrapper of a Map whose semigroup operation is the symmetric -- difference, and ergo whose monoidal unit is empty newtype SymmetricDifference map a SymmetricDifference :: map a -> SymmetricDifference map a [unSymmetricDifference] :: SymmetricDifference map a -> map a instance Data.Functor.Classes.Show1 map => Data.Functor.Classes.Show1 (Data.Map.Class.SymmetricDifference map) instance Data.Functor.Classes.Read1 map => Data.Functor.Classes.Read1 (Data.Map.Class.SymmetricDifference map) instance Data.Functor.Classes.Ord1 map => Data.Functor.Classes.Ord1 (Data.Map.Class.SymmetricDifference map) instance Data.Functor.Classes.Eq1 map => Data.Functor.Classes.Eq1 (Data.Map.Class.SymmetricDifference map) instance forall k (map :: k -> *) (a :: k). GHC.Show.Show (map a) => GHC.Show.Show (Data.Map.Class.SymmetricDifference map a) instance forall k (map :: k -> *) (a :: k). GHC.Read.Read (map a) => GHC.Read.Read (Data.Map.Class.SymmetricDifference map a) instance forall k (map :: k -> *) (a :: k). GHC.Classes.Ord (map a) => GHC.Classes.Ord (Data.Map.Class.SymmetricDifference map a) instance forall k (map :: k -> *) (a :: k). GHC.Classes.Eq (map a) => GHC.Classes.Eq (Data.Map.Class.SymmetricDifference map a) instance Data.Traversable.Traversable map => Data.Traversable.Traversable (Data.Map.Class.SymmetricDifference map) instance Data.Foldable.Foldable map => Data.Foldable.Foldable (Data.Map.Class.SymmetricDifference map) instance GHC.Base.Functor map => GHC.Base.Functor (Data.Map.Class.SymmetricDifference map) instance Data.Functor.Classes.Show1 map => Data.Functor.Classes.Show1 (Data.Map.Class.Intersection map) instance Data.Functor.Classes.Read1 map => Data.Functor.Classes.Read1 (Data.Map.Class.Intersection map) instance Data.Functor.Classes.Ord1 map => Data.Functor.Classes.Ord1 (Data.Map.Class.Intersection map) instance Data.Functor.Classes.Eq1 map => Data.Functor.Classes.Eq1 (Data.Map.Class.Intersection map) instance forall k (map :: k -> *) (a :: k). GHC.Show.Show (map a) => GHC.Show.Show (Data.Map.Class.Intersection map a) instance forall k (map :: k -> *) (a :: k). GHC.Read.Read (map a) => GHC.Read.Read (Data.Map.Class.Intersection map a) instance forall k (map :: k -> *) (a :: k). GHC.Classes.Ord (map a) => GHC.Classes.Ord (Data.Map.Class.Intersection map a) instance forall k (map :: k -> *) (a :: k). GHC.Classes.Eq (map a) => GHC.Classes.Eq (Data.Map.Class.Intersection map a) instance Data.Traversable.Traversable map => Data.Traversable.Traversable (Data.Map.Class.Intersection map) instance Data.Foldable.Foldable map => Data.Foldable.Foldable (Data.Map.Class.Intersection map) instance GHC.Base.Functor map => GHC.Base.Functor (Data.Map.Class.Intersection map) instance Data.Functor.Classes.Show1 map => Data.Functor.Classes.Show1 (Data.Map.Class.Union map) instance Data.Functor.Classes.Read1 map => Data.Functor.Classes.Read1 (Data.Map.Class.Union map) instance Data.Functor.Classes.Ord1 map => Data.Functor.Classes.Ord1 (Data.Map.Class.Union map) instance Data.Functor.Classes.Eq1 map => Data.Functor.Classes.Eq1 (Data.Map.Class.Union map) instance forall k (map :: k -> *) (a :: k). GHC.Show.Show (map a) => GHC.Show.Show (Data.Map.Class.Union map a) instance forall k (map :: k -> *) (a :: k). GHC.Read.Read (map a) => GHC.Read.Read (Data.Map.Class.Union map a) instance forall k (map :: k -> *) (a :: k). GHC.Classes.Ord (map a) => GHC.Classes.Ord (Data.Map.Class.Union map a) instance forall k (map :: k -> *) (a :: k). GHC.Classes.Eq (map a) => GHC.Classes.Eq (Data.Map.Class.Union map a) instance Data.Traversable.Traversable map => Data.Traversable.Traversable (Data.Map.Class.Union map) instance Data.Foldable.Foldable map => Data.Foldable.Foldable (Data.Map.Class.Union map) instance GHC.Base.Functor map => GHC.Base.Functor (Data.Map.Class.Union map) instance Data.Filtrable.Filtrable map => Data.Filtrable.Filtrable (Data.Map.Class.SymmetricDifference map) instance Data.Map.Class.StaticMap map => Data.Map.Class.StaticMap (Data.Map.Class.SymmetricDifference map) instance Data.Map.Class.Map map => Data.Map.Class.Map (Data.Map.Class.SymmetricDifference map) instance Data.Map.Class.Map map => GHC.Base.Semigroup (Data.Map.Class.SymmetricDifference map a) instance Data.Map.Class.Map map => GHC.Base.Monoid (Data.Map.Class.SymmetricDifference map a) instance Data.Filtrable.Filtrable map => Data.Filtrable.Filtrable (Data.Map.Class.Intersection map) instance Data.Map.Class.StaticMap map => Data.Map.Class.StaticMap (Data.Map.Class.Intersection map) instance Data.Map.Class.Map map => Data.Map.Class.Map (Data.Map.Class.Intersection map) instance (Data.Map.Class.Map map, GHC.Base.Semigroup a) => GHC.Base.Semigroup (Data.Map.Class.Intersection map a) instance Data.Filtrable.Filtrable map => Data.Filtrable.Filtrable (Data.Map.Class.Union map) instance Data.Map.Class.StaticMap map => Data.Map.Class.StaticMap (Data.Map.Class.Union map) instance Data.Map.Class.Map map => Data.Map.Class.Map (Data.Map.Class.Union map) instance (Data.Map.Class.Map map, GHC.Base.Semigroup a) => GHC.Base.Semigroup (Data.Map.Class.Union map a) instance (Data.Map.Class.Map map, GHC.Base.Semigroup a) => GHC.Base.Monoid (Data.Map.Class.Union map a) instance Data.Map.Class.Map GHC.Maybe.Maybe instance Data.Map.Class.Map Data.IntMap.Internal.IntMap instance GHC.Classes.Ord key => Data.Map.Class.Map (Data.Map.Internal.Map key) instance (Data.Map.Class.Map m, Data.Map.Class.Map n) => Data.Map.Class.Map (Data.Functor.Compose.Compose m n) instance (Data.Map.Class.Map m, Data.Map.Class.Map n) => Data.Map.Class.Map (Data.Functor.Product.Product m n) instance Data.Map.Class.StaticMap GHC.Maybe.Maybe instance Data.Map.Class.StaticMap Data.IntMap.Internal.IntMap instance GHC.Classes.Ord key => Data.Map.Class.StaticMap (Data.Map.Internal.Map key) instance (Data.Map.Class.StaticMap m, Data.Map.Class.StaticMap n) => Data.Map.Class.StaticMap (Data.Functor.Compose.Compose m n) instance (Data.Map.Class.StaticMap m, Data.Map.Class.StaticMap n) => Data.Map.Class.StaticMap (Data.Functor.Product.Product m n)