refined-containers 0.1.1.0 → 0.1.2.0
raw patch · 8 files changed
+62/−10 lines, 8 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Data.Map.Strict.Refined: zipWith :: forall s k a b c. Ord k => (a -> b -> c) -> Map s k a -> Map s k b -> Map s k c
Files
- refined-containers.cabal +1/−1
- src/Data/HashMap/Common/Refined.hs +3/−3
- src/Data/HashMap/Refined.hs +2/−1
- src/Data/HashMap/Strict/Refined.hs +9/−1
- src/Data/IntMap/Refined.hs +2/−1
- src/Data/IntMap/Strict/Refined.hs +23/−1
- src/Data/Map/Refined.hs +2/−1
- src/Data/Map/Strict/Refined.hs +20/−1
refined-containers.cabal view
@@ -23,7 +23,7 @@ license-file: LICENSE author: mniip@typeable.io maintainer: mniip@typeable.io-version: 0.1.1.0+version: 0.1.2.0 build-type: Simple tested-with:
src/Data/HashMap/Common/Refined.hs view
@@ -474,7 +474,7 @@ itraverse = traverseWithKey -- | Similar to the instance for functions -- zip corresponding keys. To use--- '<*>'/'Control.Applicative.liftA2' without 'KnownSet' see 'zipWith'.+-- '<*>'/'Control.Applicative.liftA2' without 'KnownHashSet' see 'zipWith'. instance (Hashable k, KnownHashSet s k) => Applicative (HashMap s k) where pure x = fromSet \_ -> x (<*>) = zipWith id@@ -486,8 +486,8 @@ => HashMap s k a -> (a -> HashMap s k b) -> HashMap s k b bind m f = mapWithKey (\k x -> f x ! k) m --- | Similar to the instance for functions. To use '>>=' without 'KnownSet' see--- 'bind'.+-- | Similar to the instance for functions. To use '>>=' without 'KnownHashSet'+-- see 'bind'. instance (Hashable k, KnownHashSet s k) => Monad (HashMap s k) where (>>=) = bind
src/Data/HashMap/Refined.hs view
@@ -344,7 +344,8 @@ ) -- | Given two maps proven to have the same keys, for each key apply the--- function to the associated values, to obtain a new map with the same keys.+-- function to the associated values and the key, to obtain a new map with the+-- same keys. zipWithKey :: forall s k a b c. Hashable k => (Key s k -> a -> b -> c) -> HashMap s k a -> HashMap s k b -> HashMap s k c
src/Data/HashMap/Strict/Refined.hs view
@@ -137,7 +137,7 @@ import qualified Data.HashMap.Strict as HashMap import Data.HashMap.Common.Refined ( HashMap(..), Key, unsafeCastKey, unsafeKey, SomeHashMapWith(..)- , Some2HashMapWith(..), (!), zipWith+ , Some2HashMapWith(..), (!) ) import qualified Data.HashMap.Common.Refined as Common import qualified Data.HashSet as HashSet@@ -353,6 +353,14 @@ -- | Given two maps proven to have the same keys, for each key apply the -- function to the associated values, to obtain a new map with the same keys.+zipWith+ :: forall s k a b c. Hashable k+ => (a -> b -> c) -> HashMap s k a -> HashMap s k b -> HashMap s k c+zipWith f (HashMap m1) (HashMap m2) = HashMap $ HashMap.intersectionWith f m1 m2++-- | Given two maps proven to have the same keys, for each key apply the+-- function to the associated values and the key, to obtain a new map with the+-- same keys. zipWithKey :: forall s k a b c. Hashable k => (Key s k -> a -> b -> c) -> HashMap s k a -> HashMap s k b -> HashMap s k c
src/Data/IntMap/Refined.hs view
@@ -337,7 +337,8 @@ $ SomeIntMapWith (IntMap m') $ SupersetProof unsafeSubset -- | Given two maps proven to have the same keys, for each key apply the--- function to the associated values, to obtain a new map with the same keys.+-- function to the associated values and the key, to obtain a new map with the+-- same keys. zipWithKey :: forall s a b c. (Key s -> a -> b -> c) -> IntMap s a
src/Data/IntMap/Strict/Refined.hs view
@@ -145,7 +145,7 @@ import qualified Data.IntMap.Strict as IntMap import Data.IntMap.Common.Refined ( IntMap(..), Key, unsafeCastKey, unsafeKey, SomeIntMapWith(..)- , Some2IntMapWith(..), (!), zipWith+ , Some2IntMapWith(..), (!) ) import qualified Data.IntMap.Common.Refined as Common import Data.Proxy@@ -344,6 +344,28 @@ -- | Given two maps proven to have the same keys, for each key apply the -- function to the associated values, to obtain a new map with the same keys.+zipWith+ :: forall s a b c. (a -> b -> c)+ -> IntMap s a+ -> IntMap s b+ -> IntMap s c+zipWith f (IntMap m1) (IntMap m2) = IntMap+ $ IntMap.mergeWithKey (\_ x y -> Just $ f x y)+ (\m -> if IntMap.null m+ then IntMap.empty+ else+ error "zipWith: bug: Data.IntMap.Strict.Refined has been subverted")+ (\m -> if IntMap.null m+ then IntMap.empty+ else+ error "zipWith: bug: Data.IntMap.Strict.Refined has been subverted")+ -- ^ Work around https://github.com/haskell/containers/issues/979+ m1+ m2++-- | Given two maps proven to have the same keys, for each key apply the+-- function to the associated values and the key, to obtain a new map with the+-- same keys. zipWithKey :: forall s a b c. (Key s -> a -> b -> c) -> IntMap s a
src/Data/Map/Refined.hs view
@@ -348,7 +348,8 @@ $ SomeMapWith (Map m') $ SupersetProof unsafeSubset -- | Given two maps proven to have the same keys, for each key apply the--- function to the associated values, to obtain a new map with the same keys.+-- function to the associated values and the key, to obtain a new map with the+-- same keys. zipWithKey :: forall s k a b c. Ord k => (Key s k -> a -> b -> c) -> Map s k a -> Map s k b -> Map s k c
src/Data/Map/Strict/Refined.hs view
@@ -78,6 +78,7 @@ , Common.disjoint , DisjointProof(..) -- * Combine+ , zipWith , zipWithKey , bind , Common.union@@ -160,7 +161,7 @@ import Data.Reflection import Data.Traversable import Data.Type.Coercion-import Prelude hiding (lookup, map, null)+import Prelude hiding (lookup, map, null, zipWith) import Refined import Refined.Unsafe @@ -355,6 +356,24 @@ -- | Given two maps proven to have the same keys, for each key apply the -- function to the associated values, to obtain a new map with the same keys.+zipWith+ :: forall s k a b c. Ord k+ => (a -> b -> c) -> Map s k a -> Map s k b -> Map s k c+zipWith f (Map m1) (Map m2) = Map+ $ Map.mergeWithKey (\_ x y -> Just $ f x y)+ (\m -> if Map.null m+ then Map.empty+ else error "zipWith: bug: Data.Map.Strict.Refined has been subverted")+ (\m -> if Map.null m+ then Map.empty+ else error "zipWith: bug: Data.Map.Strict.Refined has been subverted")+ -- ^ Work around https://github.com/haskell/containers/issues/979+ m1+ m2++-- | Given two maps proven to have the same keys, for each key apply the+-- function to the associated values and the key, to obtain a new map with the+-- same keys. zipWithKey :: forall s k a b c. Ord k => (Key s k -> a -> b -> c) -> Map s k a -> Map s k b -> Map s k c