--------------------------------------------------------------
-- Common Indexed Traversals
------------------------------------------------------------------------------

-- | Access the element of an 'IndexedTraversal' where the index matches a predicate.
--
-- >>> over (iwhereOf traversed (>0)) reverse ["He","was","stressed","o_O"]
-- ["He","saw","desserts","O_o"]
--
-- @
-- 'iwhereOf' :: 'Control.Lens.IndexedFold.IndexedFold' i s a            -> (i -> 'Bool') -> 'Control.Lens.IndexedFold.IndexedFold' i s a
-- 'iwhereOf' :: 'IndexedGetter' i s a          -> (i -> 'Bool') -> 'Control.Lens.IndexedFold.IndexedFold' i s a
-- 'iwhereOf' :: 'IndexedLens'' i s a      -> (i -> 'Bool') -> 'IndexedTraversal'' i s a
-- 'iwhereOf' :: 'IndexedTraversal'' i s a -> (i -> 'Bool') -> 'IndexedTraversal'' i s a
-- 'iwhereOf' :: 'IndexedSetter'' i s a    -> (i -> 'Bool') -> 'IndexedSetter'' i s a
-- @
iwhereOf :: (Indexable i p, Applicative f) => IndexedLensLike (Indexed i) f s t a a -> (i -> Bool) -> IndexedLensLike p f s t a a
iwhereOf l p f = withIndex l (\i a -> if p i then indexed f i a else pure a)
{-# INLINE iwhe
iwhereOf :: (Indexable i p, Applicative f) => IndexedLensLike (Indexed i) f s t a a -> (i -> Bool) -> IndexedLensLike p f s t a a
iwhereOf l p f = withIndex l (\i a -> if p i then indexed f i a else pure a)
iwhereOf l p f = withIndex l (\i a -> if p i then indexed f i a else pure a)