Map 0.0.1.1 → 0.0.2.0
raw patch · 2 files changed
+16/−13 lines, 2 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Data.Map.Class: instance (GHC.Classes.Ord k, GHC.Base.Semigroup a) => GHC.Base.Monoid (Data.Map.Class.Union (Data.Map.Internal.Map k) a)
- Data.Map.Class: instance GHC.Base.Monoid (Data.Map.Class.SymmetricDifference Data.IntMap.Internal.IntMap a)
- Data.Map.Class: instance GHC.Base.Semigroup a => GHC.Base.Monoid (Data.Map.Class.Union Data.IntMap.Internal.IntMap a)
- Data.Map.Class: instance GHC.Classes.Ord k => GHC.Base.Monoid (Data.Map.Class.SymmetricDifference (Data.Map.Internal.Map k) a)
+ Data.Map.Class: empty :: Map map => map a
+ Data.Map.Class: instance (Data.Map.Class.Map map, GHC.Base.Semigroup a) => GHC.Base.Monoid (Data.Map.Class.Union map a)
+ Data.Map.Class: instance Data.Map.Class.Map map => GHC.Base.Monoid (Data.Map.Class.SymmetricDifference map a)
Files
- Data/Map/Class.hs +14/−11
- Map.cabal +2/−2
Data/Map/Class.hs view
@@ -1,6 +1,6 @@ module Data.Map.Class where -import Control.Applicative+import Control.Applicative hiding (empty) import Control.Arrow import Control.Monad import Data.Either.Both@@ -22,6 +22,7 @@ adjustA :: Applicative p => (a -> p a) -> Key map -> map a -> p (map a) class (Filtrable map, StaticMap map) => Map map where+ empty :: map a alterF :: Functor f => (Maybe a -> f (Maybe a)) -> Key map -> map a -> f (map a) mergeA :: Applicative p => (Key map -> Either' a b -> p (Maybe c)) -> map a -> map b -> p (map c) mapMaybeWithKeyA :: Applicative p => (Key map -> a -> p (Maybe b)) -> map a -> p (map b)@@ -61,11 +62,13 @@ Right j -> id Pair a <$> adjustA f j b instance Map Maybe where+ empty = Nothing alterF f () = f mergeA f = mapMaybeWithKeyA f ∘∘ fromMaybes mapMaybeWithKeyA f = fmap join . traverse (f ()) instance Map IntMap where+ empty = Int.empty alterF = Int.alterF mergeA f = mapMaybeWithKeyA f ∘∘ Int.mergeWithKey (pure $ Just ∘∘ Both) (fmap JustLeft) (fmap JustRight)@@ -73,6 +76,7 @@ mapEitherWithKeyA f = fmap partitionEithers . Int.traverseWithKey f instance Ord key => Map (M.Map key) where+ empty = M.empty alterF = M.alterF mergeA f = M.mergeA (M.traverseMaybeMissing $ \ k a -> f k (JustLeft a)) (M.traverseMaybeMissing $ \ k b -> f k (JustRight b))@@ -81,6 +85,7 @@ mapEitherWithKeyA f = fmap partitionEithers . M.traverseWithKey f instance (Map m, Map n) => Map (Compose m n) where+ empty = Compose empty alterF f (i, j) = fmap Compose . alterF (maybe (Nothing <$ f Nothing) (fmap Just . alterF f j)) i . getCompose mergeA f = fmap Compose ∘∘@@ -91,6 +96,7 @@ mapMaybeWithKeyA f = fmap Compose . mapMaybeWithKeyA (\ i -> fmap Just . mapMaybeWithKeyA (\ j -> f (i, j))) . getCompose instance (Map m, Map n) => Map (Product m n) where+ empty = Pair empty empty alterF f k (Pair a b) = case k of Left i -> flip Pair b <$> alterF f i a Right j -> id Pair a <$> alterF f j b@@ -125,6 +131,7 @@ adjustA f k = fmap Union . adjustA f k . unUnion instance Map map => Map (Union map) where+ empty = Union empty alterF f k = fmap Union . alterF f k . unUnion mergeA f = fmap Union ∘∘ compose2 (mergeA f) unUnion unUnion mapMaybeWithKeyA f = fmap Union . mapMaybeWithKeyA f . unUnion@@ -132,11 +139,8 @@ instance (Map map, Semigroup a) => Semigroup (Union map a) where (<>) = Union ∘∘ runIdentity ∘∘ mergeA (pure $ Identity ∘ Just ∘ either' id id (<>)) `on` unUnion -instance (Ord k, Semigroup a) => Monoid (Union (M.Map k) a) where- mempty = Union M.empty--instance Semigroup a => Monoid (Union IntMap a) where- mempty = Union Int.empty+instance (Map map, Semigroup a) => Monoid (Union map a) where+ mempty = Union empty newtype Intersection map a = Intersection { unIntersection :: map a } deriving (Functor, Foldable, Traversable)@@ -150,6 +154,7 @@ adjustA f k = fmap Intersection . adjustA f k . unIntersection instance Map map => Map (Intersection map) where+ empty = Intersection empty alterF f k = fmap Intersection . alterF f k . unIntersection mergeA f = fmap Intersection ∘∘ compose2 (mergeA f) unIntersection unIntersection mapMaybeWithKeyA f = fmap Intersection . mapMaybeWithKeyA f . unIntersection@@ -169,6 +174,7 @@ adjustA f k = fmap SymmetricDifference . adjustA f k . unSymmetricDifference instance Map map => Map (SymmetricDifference map) where+ empty = SymmetricDifference empty alterF f k = fmap SymmetricDifference . alterF f k . unSymmetricDifference mergeA f = fmap SymmetricDifference ∘∘ compose2 (mergeA f) unSymmetricDifference unSymmetricDifference mapMaybeWithKeyA f = fmap SymmetricDifference . mapMaybeWithKeyA f . unSymmetricDifference@@ -176,8 +182,5 @@ instance Map map => Semigroup (SymmetricDifference map a) where (<>) = SymmetricDifference ∘∘ merge (pure $ either' Just Just (\ _ _ -> Nothing)) `on` unSymmetricDifference -instance Ord k => Monoid (SymmetricDifference (M.Map k) a) where- mempty = SymmetricDifference M.empty--instance Monoid (SymmetricDifference IntMap a) where- mempty = SymmetricDifference Int.empty+instance Map map => Monoid (SymmetricDifference map a) where+ mempty = SymmetricDifference empty
Map.cabal view
@@ -1,5 +1,5 @@ name: Map-version: 0.0.1.1+version: 0.0.2.0 synopsis: Class of key-value maps -- description: license: BSD3@@ -16,7 +16,7 @@ hs-source-dirs: . exposed-modules: Data.Map.Class build-depends: base >= 4.7 && < 5- , containers >=0.5.9 && <0.6+ , containers >=0.5.9 && <0.7 , either-both >=0.1.1 && <0.2 , filtrable >=0.1.2 && <0.2 , util >=0.1.10 && <0.2