Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export findIndexR from the non-generic vector modules #469

Merged
merged 2 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading