Skip to content

Commit 764e7a8

Browse files
authored
Merge pull request #110 from gilgamec/master
Changed indexes provided to accum to type-safe Finites.
2 parents 45ef035 + eb0e755 commit 764e7a8

8 files changed

Lines changed: 15 additions & 10 deletions

File tree

changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## WIP
44

5+
## [1.5.0] - 2021-08-25
6+
7+
- Change indexes used by `accum` from `Int` to `Finite`.
8+
59
## [1.4.4] - 2021-06-26
610

711
- Add `ix'`

package.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: vector-sized
2-
version: 1.4.4
2+
version: 1.5.0
33
synopsis: Size tagged vectors
44
description: Please see README.md
55
category: Data

src/Data/Vector/Generic/Sized.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -927,9 +927,10 @@ unsafeUpdate_ (Vector v) (Vector is) (Vector w) =
927927
accum :: VG.Vector v a
928928
=> (a -> b -> a) -- ^ accumulating function @f@
929929
-> Vector v m a -- ^ initial vector (of length @m@)
930-
-> [(Int,b)] -- ^ list of index/value pairs (of length @n@)
930+
-> [(Finite m,b)] -- ^ list of index/value pairs (of length @n@)
931931
-> Vector v m a
932-
accum f (Vector v) us = Vector (VG.accum f v us)
932+
accum f (Vector v) us =
933+
Vector (VG.accum f v $ (fmap . first) (fromIntegral . getFinite) us)
933934
{-# inline accum #-}
934935

935936
-- | /O(m+n)/ For each pair @(i,b)@ from the vector of pairs, replace the vector

src/Data/Vector/Primitive/Sized.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ unsafeUpdate_ = V.unsafeUpdate_
706706
accum :: Prim a
707707
=> (a -> b -> a) -- ^ accumulating function @f@
708708
-> Vector m a -- ^ initial vector (of length @m@)
709-
-> [(Int,b)] -- ^ list of index/value pairs (of length @n@)
709+
-> [(Finite m,b)] -- ^ list of index/value pairs (of length @n@)
710710
-> Vector m a
711711
accum = V.accum
712712
{-# inline accum #-}

src/Data/Vector/Sized.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,7 @@ unsafeUpdate_ = V.unsafeUpdate_
741741
-- > accum (+) <5,9,2> [(2,4),(1,6),(0,3),(1,7)] = <5+3, 9+6+7, 2+4>
742742
accum :: (a -> b -> a) -- ^ accumulating function @f@
743743
-> Vector m a -- ^ initial vector (of length @m@)
744-
-> [(Int,b)] -- ^ list of index/value pairs (of length @n@)
744+
-> [(Finite m,b)] -- ^ list of index/value pairs (of length @n@)
745745
-> Vector m a
746746
accum = V.accum
747747
{-# inline accum #-}

src/Data/Vector/Storable/Sized.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ unsafeUpdate_ = V.unsafeUpdate_
761761
accum :: Storable a
762762
=> (a -> b -> a) -- ^ accumulating function @f@
763763
-> Vector m a -- ^ initial vector (of length @m@)
764-
-> [(Int,b)] -- ^ list of index/value pairs (of length @n@)
764+
-> [(Finite m,b)] -- ^ list of index/value pairs (of length @n@)
765765
-> Vector m a
766766
accum = V.accum
767767
{-# inline accum #-}

src/Data/Vector/Unboxed/Sized.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ unsafeUpdate_ = V.unsafeUpdate_
762762
accum :: Unbox a
763763
=> (a -> b -> a) -- ^ accumulating function @f@
764764
-> Vector m a -- ^ initial vector (of length @m@)
765-
-> [(Int,b)] -- ^ list of index/value pairs (of length @n@)
765+
-> [(Finite m,b)] -- ^ list of index/value pairs (of length @n@)
766766
-> Vector m a
767767
accum = V.accum
768768
{-# inline accum #-}

vector-sized.cabal

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
cabal-version: 1.12
22

3-
-- This file has been generated from package.yaml by hpack version 0.33.0.
3+
-- This file has been generated from package.yaml by hpack version 0.34.4.
44
--
55
-- see: https://github.com/sol/hpack
66
--
7-
-- hash: e36af7d31e151c5e8d7ad5636dd5d31b47e82d6fe6384f8f76753ed0e17b61b1
7+
-- hash: 8cc33c7ff1b35236dcaed143ba951337eb4f12e3c53c616fa15ec2a073c0942b
88

99
name: vector-sized
10-
version: 1.4.4
10+
version: 1.5.0
1111
synopsis: Size tagged vectors
1212
description: Please see README.md
1313
category: Data

0 commit comments

Comments
 (0)