diff --git a/changelog.md b/changelog.md index 1607546..9263c10 100644 --- a/changelog.md +++ b/changelog.md @@ -2,6 +2,10 @@ ## WIP +## [1.5.0] - 2021-08-25 + +- Change indexes used by `accum` from `Int` to `Finite`. + ## [1.4.4] - 2021-06-26 - Add `ix'` diff --git a/package.yaml b/package.yaml index 6760c12..91f7239 100644 --- a/package.yaml +++ b/package.yaml @@ -1,5 +1,5 @@ name: vector-sized -version: 1.4.4 +version: 1.5.0 synopsis: Size tagged vectors description: Please see README.md category: Data diff --git a/src/Data/Vector/Generic/Sized.hs b/src/Data/Vector/Generic/Sized.hs index b1ac9c3..e669c5c 100755 --- a/src/Data/Vector/Generic/Sized.hs +++ b/src/Data/Vector/Generic/Sized.hs @@ -927,9 +927,10 @@ unsafeUpdate_ (Vector v) (Vector is) (Vector w) = accum :: VG.Vector v a => (a -> b -> a) -- ^ accumulating function @f@ -> Vector v m a -- ^ initial vector (of length @m@) - -> [(Int,b)] -- ^ list of index/value pairs (of length @n@) + -> [(Finite m,b)] -- ^ list of index/value pairs (of length @n@) -> Vector v m a -accum f (Vector v) us = Vector (VG.accum f v us) +accum f (Vector v) us = + Vector (VG.accum f v $ (fmap . first) (fromIntegral . getFinite) us) {-# inline accum #-} -- | /O(m+n)/ For each pair @(i,b)@ from the vector of pairs, replace the vector diff --git a/src/Data/Vector/Primitive/Sized.hs b/src/Data/Vector/Primitive/Sized.hs index da18129..c148030 100644 --- a/src/Data/Vector/Primitive/Sized.hs +++ b/src/Data/Vector/Primitive/Sized.hs @@ -706,7 +706,7 @@ unsafeUpdate_ = V.unsafeUpdate_ accum :: Prim a => (a -> b -> a) -- ^ accumulating function @f@ -> Vector m a -- ^ initial vector (of length @m@) - -> [(Int,b)] -- ^ list of index/value pairs (of length @n@) + -> [(Finite m,b)] -- ^ list of index/value pairs (of length @n@) -> Vector m a accum = V.accum {-# inline accum #-} diff --git a/src/Data/Vector/Sized.hs b/src/Data/Vector/Sized.hs index f8a8465..19b04ce 100644 --- a/src/Data/Vector/Sized.hs +++ b/src/Data/Vector/Sized.hs @@ -741,7 +741,7 @@ unsafeUpdate_ = V.unsafeUpdate_ -- > accum (+) <5,9,2> [(2,4),(1,6),(0,3),(1,7)] = <5+3, 9+6+7, 2+4> accum :: (a -> b -> a) -- ^ accumulating function @f@ -> Vector m a -- ^ initial vector (of length @m@) - -> [(Int,b)] -- ^ list of index/value pairs (of length @n@) + -> [(Finite m,b)] -- ^ list of index/value pairs (of length @n@) -> Vector m a accum = V.accum {-# inline accum #-} diff --git a/src/Data/Vector/Storable/Sized.hs b/src/Data/Vector/Storable/Sized.hs index 68a24d1..7b326f0 100644 --- a/src/Data/Vector/Storable/Sized.hs +++ b/src/Data/Vector/Storable/Sized.hs @@ -761,7 +761,7 @@ unsafeUpdate_ = V.unsafeUpdate_ accum :: Storable a => (a -> b -> a) -- ^ accumulating function @f@ -> Vector m a -- ^ initial vector (of length @m@) - -> [(Int,b)] -- ^ list of index/value pairs (of length @n@) + -> [(Finite m,b)] -- ^ list of index/value pairs (of length @n@) -> Vector m a accum = V.accum {-# inline accum #-} diff --git a/src/Data/Vector/Unboxed/Sized.hs b/src/Data/Vector/Unboxed/Sized.hs index 57b3b27..6c142b6 100644 --- a/src/Data/Vector/Unboxed/Sized.hs +++ b/src/Data/Vector/Unboxed/Sized.hs @@ -762,7 +762,7 @@ unsafeUpdate_ = V.unsafeUpdate_ accum :: Unbox a => (a -> b -> a) -- ^ accumulating function @f@ -> Vector m a -- ^ initial vector (of length @m@) - -> [(Int,b)] -- ^ list of index/value pairs (of length @n@) + -> [(Finite m,b)] -- ^ list of index/value pairs (of length @n@) -> Vector m a accum = V.accum {-# inline accum #-} diff --git a/vector-sized.cabal b/vector-sized.cabal index df1608f..c45787d 100644 --- a/vector-sized.cabal +++ b/vector-sized.cabal @@ -1,13 +1,13 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.33.0. +-- This file has been generated from package.yaml by hpack version 0.34.4. -- -- see: https://github.com/sol/hpack -- --- hash: e36af7d31e151c5e8d7ad5636dd5d31b47e82d6fe6384f8f76753ed0e17b61b1 +-- hash: 8cc33c7ff1b35236dcaed143ba951337eb4f12e3c53c616fa15ec2a073c0942b name: vector-sized -version: 1.4.4 +version: 1.5.0 synopsis: Size tagged vectors description: Please see README.md category: Data