Skip to content

Commit

Permalink
Merge pull request #469 from toyboot4e/export-findIndexR
Browse files Browse the repository at this point in the history
Export `findIndexR` from the non-generic vector modules
  • Loading branch information
Shimuuar committed Sep 19, 2023
2 parents dd10829 + 6fedacd commit c88d0d2
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 4 deletions.
10 changes: 9 additions & 1 deletion vector/src/Data/Vector.hs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ module Data.Vector (
partition, unstablePartition, partitionWith, span, break, groupBy, group,

-- ** Searching
elem, notElem, find, findIndex, findIndices, elemIndex, elemIndices,
elem, notElem, find, findIndex, findIndexR, findIndices, elemIndex, elemIndices,

-- * Folding
foldl, foldl1, foldl', foldl1', foldr, foldr1, foldr', foldr1',
Expand Down Expand Up @@ -1477,6 +1477,14 @@ findIndex :: (a -> Bool) -> Vector a -> Maybe Int
{-# INLINE findIndex #-}
findIndex = G.findIndex

-- | /O(n)/ Yield 'Just' the index of the /last/ element matching the predicate
-- or 'Nothing' if no such element exists.
--
-- Does not fuse.
findIndexR :: (a -> Bool) -> Vector a -> Maybe Int
{-# INLINE findIndexR #-}
findIndexR = G.findIndexR

-- | /O(n)/ Yield the indices of elements satisfying the predicate in ascending
-- order.
findIndices :: (a -> Bool) -> Vector a -> Vector Int
Expand Down
2 changes: 2 additions & 0 deletions vector/src/Data/Vector/Generic.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1620,6 +1620,8 @@ findIndex f = Bundle.findIndex f . stream
-- | /O(n)/ Yield 'Just' the index of the /last/ element matching the predicate
-- or 'Nothing' if no such element exists.
--
-- Does not fuse.
--
-- @since 0.12.2.0
findIndexR :: Vector v a => (a -> Bool) -> v a -> Maybe Int
{-# INLINE findIndexR #-}
Expand Down
10 changes: 9 additions & 1 deletion vector/src/Data/Vector/Primitive.hs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ module Data.Vector.Primitive (
partition, unstablePartition, partitionWith, span, break, groupBy, group,

-- ** Searching
elem, notElem, find, findIndex, findIndices, elemIndex, elemIndices,
elem, notElem, find, findIndex, findIndexR, findIndices, elemIndex, elemIndices,

-- * Folding
foldl, foldl1, foldl', foldl1', foldr, foldr1, foldr', foldr1',
Expand Down Expand Up @@ -1233,6 +1233,14 @@ findIndex :: Prim a => (a -> Bool) -> Vector a -> Maybe Int
{-# INLINE findIndex #-}
findIndex = G.findIndex

-- | /O(n)/ Yield 'Just' the index of the /last/ element matching the predicate
-- or 'Nothing' if no such element exists.
--
-- Does not fuse.
findIndexR :: Prim a => (a -> Bool) -> Vector a -> Maybe Int
{-# INLINE findIndexR #-}
findIndexR = G.findIndexR

-- | /O(n)/ Yield the indices of elements satisfying the predicate in ascending
-- order.
findIndices :: Prim a => (a -> Bool) -> Vector a -> Vector Int
Expand Down
10 changes: 9 additions & 1 deletion vector/src/Data/Vector/Storable.hs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ module Data.Vector.Storable (
partition, unstablePartition, partitionWith, span, break, groupBy, group,

-- ** Searching
elem, notElem, find, findIndex, findIndices, elemIndex, elemIndices,
elem, notElem, find, findIndex, findIndexR, findIndices, elemIndex, elemIndices,

-- * Folding
foldl, foldl1, foldl', foldl1', foldr, foldr1, foldr', foldr1',
Expand Down Expand Up @@ -1255,6 +1255,14 @@ findIndex :: Storable a => (a -> Bool) -> Vector a -> Maybe Int
{-# INLINE findIndex #-}
findIndex = G.findIndex

-- | /O(n)/ Yield 'Just' the index of the /last/ element matching the predicate
-- or 'Nothing' if no such element exists.
--
-- Does not fuse.
findIndexR :: Storable a => (a -> Bool) -> Vector a -> Maybe Int
{-# INLINE findIndexR #-}
findIndexR = G.findIndexR

-- | /O(n)/ Yield the indices of elements satisfying the predicate in ascending
-- order.
findIndices :: Storable a => (a -> Bool) -> Vector a -> Vector Int
Expand Down
10 changes: 9 additions & 1 deletion vector/src/Data/Vector/Unboxed.hs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ module Data.Vector.Unboxed (
partition, unstablePartition, partitionWith, span, break, groupBy, group,

-- ** Searching
elem, notElem, find, findIndex, findIndices, elemIndex, elemIndices,
elem, notElem, find, findIndex, findIndexR, findIndices, elemIndex, elemIndices,

-- * Folding
foldl, foldl1, foldl', foldl1', foldr, foldr1, foldr', foldr1',
Expand Down Expand Up @@ -1244,6 +1244,14 @@ findIndex :: Unbox a => (a -> Bool) -> Vector a -> Maybe Int
{-# INLINE findIndex #-}
findIndex = G.findIndex

-- | /O(n)/ Yield 'Just' the index of the /last/ element matching the predicate
-- or 'Nothing' if no such element exists.
--
-- Does not fuse.
findIndexR :: Unbox a => (a -> Bool) -> Vector a -> Maybe Int
{-# INLINE findIndexR #-}
findIndexR = G.findIndexR

-- | /O(n)/ Yield the indices of elements satisfying the predicate in ascending
-- order.
findIndices :: Unbox a => (a -> Bool) -> Vector a -> Vector Int
Expand Down

0 comments on commit c88d0d2

Please sign in to comment.