Data.Foldable.WithIndex

indexed-traversable-0.1.4: FunctorWithIndex, FoldableWithIndex, TraversableWithIndex

Safe Haskell | Safe
Language | Haskell2010

Data.Foldable.WithIndex

Contents

- Indexed Foldables
  - Indexed Foldable Combinators

Description

Indexed Foldables.

Synopsis

- class Foldable f => FoldableWithIndex i (f :: Type -> Type) | f -> i where
  - ifoldMap :: Monoid m => (i -> a -> m) -> f a -> m
  - ifoldMap' :: Monoid m => (i -> a -> m) -> f a -> m
  - ifoldr :: (i -> a -> b -> b) -> b -> f a -> b
  - ifoldl :: (i -> b -> a -> b) -> b -> f a -> b
  - ifoldr' :: (i -> a -> b -> b) -> b -> f a -> b
  - ifoldl' :: (i -> b -> a -> b) -> b -> f a -> b
- iany :: FoldableWithIndex i f => (i -> a -> Bool) -> f a -> Bool
- iall :: FoldableWithIndex i f => (i -> a -> Bool) -> f a -> Bool
- inone :: FoldableWithIndex i f => (i -> a -> Bool) -> f a -> Bool
- none :: Foldable f => (a -> Bool) -> f a -> Bool
- itraverse_ :: (FoldableWithIndex i t, Applicative f) => (i -> a -> f b) -> t a -> f ()
- ifor_ :: (FoldableWithIndex i t, Applicative f) => t a -> (i -> a -> f b) -> f ()
- imapM_ :: (FoldableWithIndex i t, Monad m) => (i -> a -> m b) -> t a -> m ()
- iforM_ :: (FoldableWithIndex i t, Monad m) => t a -> (i -> a -> m b) -> m ()
- iconcatMap :: FoldableWithIndex i f => (i -> a -> [b]) -> f a -> [b]
- ifind :: FoldableWithIndex i f => (i -> a -> Bool) -> f a -> Maybe (i, a)
- ifoldrM :: (FoldableWithIndex i f, Monad m) => (i -> a -> b -> m b) -> b -> f a -> m b
- ifoldlM :: (FoldableWithIndex i f, Monad m) => (i -> b -> a -> m b) -> b -> f a -> m b
- itoList :: FoldableWithIndex i f => f a -> [(i, a)]

# Indexed Foldables

class Foldable f => FoldableWithIndex i (f :: Type -> Type) | f -> i where #

A container that supports folding with an additional index.

Minimal complete definition

Nothing

Methods

ifoldMap :: Monoid m => (i -> a -> m) -> f a -> m #

Fold a container by mapping value to an arbitrary `Monoid` with access to the index `i`.

When you don't need access to the index then `foldMap` is more flexible in what it accepts.

    foldMap ≡ ifoldMap . const

default ifoldMap :: (TraversableWithIndex i f, Monoid m) => (i -> a -> m) -> f a -> m #

ifoldMap' :: Monoid m => (i -> a -> m) -> f a -> m #

A variant of `ifoldMap` that is strict in the accumulator.

When you don't need access to the index then `foldMap'` is more flexible in what it accepts.

    foldMap' ≡ ifoldMap' . const

ifoldr :: (i -> a -> b -> b) -> b -> f a -> b #

Right-associative fold of an indexed container with access to the index `i`.

When you don't need access to the index then `foldr` is more flexible in what it accepts.

    foldr ≡ ifoldr . const

ifoldl :: (i -> b -> a -> b) -> b -> f a -> b #

Left-associative fold of an indexed container with access to the index `i`.

When you don't need access to the index then `foldl` is more flexible in what it accepts.

    foldl ≡ ifoldl . const

ifoldr' :: (i -> a -> b -> b) -> b -> f a -> b #

Strictly fold right over the elements of a structure with access to the index `i`.

When you don't need access to the index then `foldr'` is more flexible in what it accepts.

    foldr' ≡ ifoldr' . const

ifoldl' :: (i -> b -> a -> b) -> b -> f a -> b #

Fold over the elements of a structure with an index, associating to the left, but strictly.

When you don't need access to the index then `foldlOf'` is more flexible in what it accepts.

    foldl' l ≡ ifoldl' l . const

#### Instances

Instances details

FoldableWithIndex () Identity # |
Instance details Defined in WithIndex Methods ifoldMap :: Monoid m => (() -> a -> m) -> Identity a -> m # ifoldMap' :: Monoid m => (() -> a -> m) -> Identity a -> m # ifoldr :: (() -> a -> b -> b) -> b -> Identity a -> b # ifoldl :: (() -> b -> a -> b) -> b -> Identity a -> b # ifoldr' :: (() -> a -> b -> b) -> b -> Identity a -> b # ifoldl' :: (() -> b -> a -> b) -> b -> Identity a -> b #
FoldableWithIndex () Par1 # |
Instance details Defined in WithIndex Methods ifoldMap :: Monoid m => (() -> a -> m) -> Par1 a -> m # ifoldMap' :: Monoid m => (() -> a -> m) -> Par1 a -> m # ifoldr :: (() -> a -> b -> b) -> b -> Par1 a -> b # ifoldl :: (() -> b -> a -> b) -> b -> Par1 a -> b # ifoldr' :: (() -> a -> b -> b) -> b -> Par1 a -> b # ifoldl' :: (() -> b -> a -> b) -> b -> Par1 a -> b #
FoldableWithIndex () Maybe # |
Instance details Defined in WithIndex Methods ifoldMap :: Monoid m => (() -> a -> m) -> Maybe a -> m # ifoldMap' :: Monoid m => (() -> a -> m) -> Maybe a -> m # ifoldr :: (() -> a -> b -> b) -> b -> Maybe a -> b # ifoldl :: (() -> b -> a -> b) -> b -> Maybe a -> b # ifoldr' :: (() -> a -> b -> b) -> b -> Maybe a -> b # ifoldl' :: (() -> b -> a -> b) -> b -> Maybe a -> b #
FoldableWithIndex Int IntMap # |
Instance details Defined in WithIndex Methods ifoldMap :: Monoid m => (Int -> a -> m) -> IntMap a -> m # ifoldMap' :: Monoid m => (Int -> a -> m) -> IntMap a -> m # ifoldr :: (Int -> a -> b -> b) -> b -> IntMap a -> b # ifoldl :: (Int -> b -> a -> b) -> b -> IntMap a -> b # ifoldr' :: (Int -> a -> b -> b) -> b -> IntMap a -> b # ifoldl' :: (Int -> b -> a -> b) -> b -> IntMap a -> b #
FoldableWithIndex Int Seq # |
Instance details Defined in WithIndex Methods ifoldMap :: Monoid m => (Int -> a -> m) -> Seq a -> m # ifoldMap' :: Monoid m => (Int -> a -> m) -> Seq a -> m # ifoldr :: (Int -> a -> b -> b) -> b -> Seq a -> b # ifoldl :: (Int -> b -> a -> b) -> b -> Seq a -> b # ifoldr' :: (Int -> a -> b -> b) -> b -> Seq a -> b # ifoldl' :: (Int -> b -> a -> b) -> b -> Seq a -> b #
FoldableWithIndex Int NonEmpty # |
Instance details Defined in WithIndex Methods ifoldMap :: Monoid m => (Int -> a -> m) -> NonEmpty a -> m # ifoldMap' :: Monoid m => (Int -> a -> m) -> NonEmpty a -> m # ifoldr :: (Int -> a -> b -> b) -> b -> NonEmpty a -> b # ifoldl :: (Int -> b -> a -> b) -> b -> NonEmpty a -> b # ifoldr' :: (Int -> a -> b -> b) -> b -> NonEmpty a -> b # ifoldl' :: (Int -> b -> a -> b) -> b -> NonEmpty a -> b #
FoldableWithIndex Int ZipList # |
Instance details Defined in WithIndex Methods ifoldMap :: Monoid m => (Int -> a -> m) -> ZipList a -> m # ifoldMap' :: Monoid m => (Int -> a -> m) -> ZipList a -> m # ifoldr :: (Int -> a -> b -> b) -> b -> ZipList a -> b # ifoldl :: (Int -> b -> a -> b) -> b -> ZipList a -> b # ifoldr' :: (Int -> a -> b -> b) -> b -> ZipList a -> b # ifoldl' :: (Int -> b -> a -> b) -> b -> ZipList a -> b #
FoldableWithIndex Int [] # |
Instance details Defined in WithIndex Methods ifoldMap :: Monoid m => (Int -> a -> m) -> [a] -> m # ifoldMap' :: Monoid m => (Int -> a -> m) -> [a] -> m # ifoldr :: (Int -> a -> b -> b) -> b -> [a] -> b # ifoldl :: (Int -> b -> a -> b) -> b -> [a] -> b # ifoldr' :: (Int -> a -> b -> b) -> b -> [a] -> b # ifoldl' :: (Int -> b -> a -> b) -> b -> [a] -> b #
FoldableWithIndex Void (Proxy :: Type -> Type) # |
Instance details Defined in WithIndex Methods ifoldMap :: Monoid m => (Void -> a -> m) -> Proxy a -> m # ifoldMap' :: Monoid m => (Void -> a -> m) -> Proxy a -> m # ifoldr :: (Void -> a -> b -> b) -> b -> Proxy a -> b # ifoldl :: (Void -> b -> a -> b) -> b -> Proxy a -> b # ifoldr' :: (Void -> a -> b -> b) -> b -> Proxy a -> b # ifoldl' :: (Void -> b -> a -> b) -> b -> Proxy a -> b #
FoldableWithIndex Void (U1 :: Type -> Type) # |
Instance details Defined in WithIndex Methods ifoldMap :: Monoid m => (Void -> a -> m) -> U1 a -> m # ifoldMap' :: Monoid m => (Void -> a -> m) -> U1 a -> m # ifoldr :: (Void -> a -> b -> b) -> b -> U1 a -> b # ifoldl :: (Void -> b -> a -> b) -> b -> U1 a -> b # ifoldr' :: (Void -> a -> b -> b) -> b -> U1 a -> b # ifoldl' :: (Void -> b -> a -> b) -> b -> U1 a -> b #
FoldableWithIndex Void (V1 :: Type -> Type) # |
Instance details Defined in WithIndex Methods ifoldMap :: Monoid m => (Void -> a -> m) -> V1 a -> m # ifoldMap' :: Monoid m => (Void -> a -> m) -> V1 a -> m # ifoldr :: (Void -> a -> b -> b) -> b -> V1 a -> b # ifoldl :: (Void -> b -> a -> b) -> b -> V1 a -> b # ifoldr' :: (Void -> a -> b -> b) -> b -> V1 a -> b # ifoldl' :: (Void -> b -> a -> b) -> b -> V1 a -> b #
Ix i => FoldableWithIndex i (Array i) # |
Instance details Defined in WithIndex Methods ifoldMap :: Monoid m => (i -> a -> m) -> Array i a -> m # ifoldMap' :: Monoid m => (i -> a -> m) -> Array i a -> m # ifoldr :: (i -> a -> b -> b) -> b -> Array i a -> b # ifoldl :: (i -> b -> a -> b) -> b -> Array i a -> b # ifoldr' :: (i -> a -> b -> b) -> b -> Array i a -> b # ifoldl' :: (i -> b -> a -> b) -> b -> Array i a -> b #
FoldableWithIndex k (Map k) # |
Instance details Defined in WithIndex Methods ifoldMap :: Monoid m => (k -> a -> m) -> Map k a -> m # ifoldMap' :: Monoid m => (k -> a -> m) -> Map k a -> m # ifoldr :: (k -> a -> b -> b) -> b -> Map k a -> b # ifoldl :: (k -> b -> a -> b) -> b -> Map k a -> b # ifoldr' :: (k -> a -> b -> b) -> b -> Map k a -> b # ifoldl' :: (k -> b -> a -> b) -> b -> Map k a -> b #
FoldableWithIndex k ((,) k) # |
Instance details Defined in WithIndex Methods ifoldMap :: Monoid m => (k -> a -> m) -> (k, a) -> m # ifoldMap' :: Monoid m => (k -> a -> m) -> (k, a) -> m # ifoldr :: (k -> a -> b -> b) -> b -> (k, a) -> b # ifoldl :: (k -> b -> a -> b) -> b -> (k, a) -> b # ifoldr' :: (k -> a -> b -> b) -> b -> (k, a) -> b # ifoldl' :: (k -> b -> a -> b) -> b -> (k, a) -> b #
FoldableWithIndex Void (Const e :: Type -> Type) # |
Instance details Defined in WithIndex Methods ifoldMap :: Monoid m => (Void -> a -> m) -> Const e a -> m # ifoldMap' :: Monoid m => (Void -> a -> m) -> Const e a -> m # ifoldr :: (Void -> a -> b -> b) -> b -> Const e a -> b # ifoldl :: (Void -> b -> a -> b) -> b -> Const e a -> b # ifoldr' :: (Void -> a -> b -> b) -> b -> Const e a -> b # ifoldl' :: (Void -> b -> a -> b) -> b -> Const e a -> b #
FoldableWithIndex Void (Constant e :: Type -> Type) # |
Instance details Defined in WithIndex Methods ifoldMap :: Monoid m => (Void -> a -> m) -> Constant e a -> m # ifoldMap' :: Monoid m => (Void -> a -> m) -> Constant e a -> m # ifoldr :: (Void -> a -> b -> b) -> b -> Constant e a -> b # ifoldl :: (Void -> b -> a -> b) -> b -> Constant e a -> b # ifoldr' :: (Void -> a -> b -> b) -> b -> Constant e a -> b # ifoldl' :: (Void -> b -> a -> b) -> b -> Constant e a -> b #
FoldableWithIndex i f => FoldableWithIndex i (Rec1 f) # |
Instance details Defined in WithIndex Methods ifoldMap :: Monoid m => (i -> a -> m) -> Rec1 f a -> m # ifoldMap' :: Monoid m => (i -> a -> m) -> Rec1 f a -> m # ifoldr :: (i -> a -> b -> b) -> b -> Rec1 f a -> b # ifoldl :: (i -> b -> a -> b) -> b -> Rec1 f a -> b # ifoldr' :: (i -> a -> b -> b) -> b -> Rec1 f a -> b # ifoldl' :: (i -> b -> a -> b) -> b -> Rec1 f a -> b #
FoldableWithIndex i f => FoldableWithIndex i (Backwards f) # |
Instance details Defined in WithIndex Methods ifoldMap :: Monoid m => (i -> a -> m) -> Backwards f a -> m # ifoldMap' :: Monoid m => (i -> a -> m) -> Backwards f a -> m # ifoldr :: (i -> a -> b -> b) -> b -> Backwards f a -> b # ifoldl :: (i -> b -> a -> b) -> b -> Backwards f a -> b # ifoldr' :: (i -> a -> b -> b) -> b -> Backwards f a -> b # ifoldl' :: (i -> b -> a -> b) -> b -> Backwards f a -> b #
FoldableWithIndex i m => FoldableWithIndex i (IdentityT m) # |
Instance details Defined in WithIndex Methods ifoldMap :: Monoid m0 => (i -> a -> m0) -> IdentityT m a -> m0 # ifoldMap' :: Monoid m0 => (i -> a -> m0) -> IdentityT m a -> m0 # ifoldr :: (i -> a -> b -> b) -> b -> IdentityT m a -> b # ifoldl :: (i -> b -> a -> b) -> b -> IdentityT m a -> b # ifoldr' :: (i -> a -> b -> b) -> b -> IdentityT m a -> b # ifoldl' :: (i -> b -> a -> b) -> b -> IdentityT m a -> b #
FoldableWithIndex i f => FoldableWithIndex i (Reverse f) # |
Instance details Defined in WithIndex Methods ifoldMap :: Monoid m => (i -> a -> m) -> Reverse f a -> m # ifoldMap' :: Monoid m => (i -> a -> m) -> Reverse f a -> m # ifoldr :: (i -> a -> b -> b) -> b -> Reverse f a -> b # ifoldl :: (i -> b -> a -> b) -> b -> Reverse f a -> b # ifoldr' :: (i -> a -> b -> b) -> b -> Reverse f a -> b # ifoldl' :: (i -> b -> a -> b) -> b -> Reverse f a -> b #
FoldableWithIndex Void (K1 i c :: Type -> Type) # |
Instance details Defined in WithIndex Methods ifoldMap :: Monoid m => (Void -> a -> m) -> K1 i c a -> m # ifoldMap' :: Monoid m => (Void -> a -> m) -> K1 i c a -> m # ifoldr :: (Void -> a -> b -> b) -> b -> K1 i c a -> b # ifoldl :: (Void -> b -> a -> b) -> b -> K1 i c a -> b # ifoldr' :: (Void -> a -> b -> b) -> b -> K1 i c a -> b # ifoldl' :: (Void -> b -> a -> b) -> b -> K1 i c a -> b #
FoldableWithIndex [Int] Tree # |
Instance details Defined in WithIndex Methods ifoldMap :: Monoid m => ([Int] -> a -> m) -> Tree a -> m # ifoldMap' :: Monoid m => ([Int] -> a -> m) -> Tree a -> m # ifoldr :: ([Int] -> a -> b -> b) -> b -> Tree a -> b # ifoldl :: ([Int] -> b -> a -> b) -> b -> Tree a -> b # ifoldr' :: ([Int] -> a -> b -> b) -> b -> Tree a -> b # ifoldl' :: ([Int] -> b -> a -> b) -> b -> Tree a -> b #
(FoldableWithIndex i f, FoldableWithIndex j g) => FoldableWithIndex (Either i j) (Product f g) # |
Instance details Defined in WithIndex Methods ifoldMap :: Monoid m => (Either i j -> a -> m) -> Product f g a -> m # ifoldMap' :: Monoid m => (Either i j -> a -> m) -> Product f g a -> m # ifoldr :: (Either i j -> a -> b -> b) -> b -> Product f g a -> b # ifoldl :: (Either i j -> b -> a -> b) -> b -> Product f g a -> b # ifoldr' :: (Either i j -> a -> b -> b) -> b -> Product f g a -> b # ifoldl' :: (Either i j -> b -> a -> b) -> b -> Product f g a -> b #
(FoldableWithIndex i f, FoldableWithIndex j g) => FoldableWithIndex (Either i j) (Sum f g) # |
Instance details Defined in WithIndex Methods ifoldMap :: Monoid m => (Either i j -> a -> m) -> Sum f g a -> m # ifoldMap' :: Monoid m => (Either i j -> a -> m) -> Sum f g a -> m # ifoldr :: (Either i j -> a -> b -> b) -> b -> Sum f g a -> b # ifoldl :: (Either i j -> b -> a -> b) -> b -> Sum f g a -> b # ifoldr' :: (Either i j -> a -> b -> b) -> b -> Sum f g a -> b # ifoldl' :: (Either i j -> b -> a -> b) -> b -> Sum f g a -> b #
(FoldableWithIndex i f, FoldableWithIndex j g) => FoldableWithIndex (Either i j) (f :*: g) # |
Instance details Defined in WithIndex Methods ifoldMap :: Monoid m => (Either i j -> a -> m) -> (f :*: g) a -> m # ifoldMap' :: Monoid m => (Either i j -> a -> m) -> (f :*: g) a -> m # ifoldr :: (Either i j -> a -> b -> b) -> b -> (f :*: g) a -> b # ifoldl :: (Either i j -> b -> a -> b) -> b -> (f :*: g) a -> b # ifoldr' :: (Either i j -> a -> b -> b) -> b -> (f :*: g) a -> b # ifoldl' :: (Either i j -> b -> a -> b) -> b -> (f :*: g) a -> b #
(FoldableWithIndex i f, FoldableWithIndex j g) => FoldableWithIndex (Either i j) (f :+: g) # |
Instance details Defined in WithIndex Methods ifoldMap :: Monoid m => (Either i j -> a -> m) -> (f :+: g) a -> m # ifoldMap' :: Monoid m => (Either i j -> a -> m) -> (f :+: g) a -> m # ifoldr :: (Either i j -> a -> b -> b) -> b -> (f :+: g) a -> b # ifoldl :: (Either i j -> b -> a -> b) -> b -> (f :+: g) a -> b # ifoldr' :: (Either i j -> a -> b -> b) -> b -> (f :+: g) a -> b # ifoldl' :: (Either i j -> b -> a -> b) -> b -> (f :+: g) a -> b #
(FoldableWithIndex i f, FoldableWithIndex j g) => FoldableWithIndex (i, j) (Compose f g) # |
Instance details Defined in WithIndex Methods ifoldMap :: Monoid m => ((i, j) -> a -> m) -> Compose f g a -> m # ifoldMap' :: Monoid m => ((i, j) -> a -> m) -> Compose f g a -> m # ifoldr :: ((i, j) -> a -> b -> b) -> b -> Compose f g a -> b # ifoldl :: ((i, j) -> b -> a -> b) -> b -> Compose f g a -> b # ifoldr' :: ((i, j) -> a -> b -> b) -> b -> Compose f g a -> b # ifoldl' :: ((i, j) -> b -> a -> b) -> b -> Compose f g a -> b #
(FoldableWithIndex i f, FoldableWithIndex j g) => FoldableWithIndex (i, j) (f :.: g) # |
Instance details Defined in WithIndex Methods ifoldMap :: Monoid m => ((i, j) -> a -> m) -> (f :.: g) a -> m # ifoldMap' :: Monoid m => ((i, j) -> a -> m) -> (f :.: g) a -> m # ifoldr :: ((i, j) -> a -> b -> b) -> b -> (f :.: g) a -> b # ifoldl :: ((i, j) -> b -> a -> b) -> b -> (f :.: g) a -> b # ifoldr' :: ((i, j) -> a -> b -> b) -> b -> (f :.: g) a -> b # ifoldl' :: ((i, j) -> b -> a -> b) -> b -> (f :.: g) a -> b #

## Indexed Foldable Combinators

iany :: FoldableWithIndex i f => (i -> a -> Bool) -> f a -> Bool #

Return whether or not any element in a container satisfies a predicate, with access to the index `i`.

When you don't need access to the index then `any` is more flexible in what it accepts.

    any ≡ iany . const

iall :: FoldableWithIndex i f => (i -> a -> Bool) -> f a -> Bool #

Return whether or not all elements in a container satisfy a predicate, with access to the index `i`.

When you don't need access to the index then `all` is more flexible in what it accepts.

    all ≡ iall . const

inone :: FoldableWithIndex i f => (i -> a -> Bool) -> f a -> Bool #

Return whether or not none of the elements in a container satisfy a predicate, with access to the index `i`.

When you don't need access to the index then `none` is more flexible in what it accepts.

    none ≡ inone . const
    inone f ≡ not . iany f

none :: Foldable f => (a -> Bool) -> f a -> Bool #

Determines whether no elements of the structure satisfy the predicate.

    none f ≡ not . any f

itraverse_ :: (FoldableWithIndex i t, Applicative f) => (i -> a -> f b) -> t a -> f () #

Traverse elements with access to the index `i`, discarding the results.

When you don't need access to the index then `traverse_` is more flexible in what it accepts.

    traverse_ l = itraverse . const

ifor_ :: (FoldableWithIndex i t, Applicative f) => t a -> (i -> a -> f b) -> f () #

Traverse elements with access to the index `i`, discarding the results (with the arguments flipped).

    ifor_ ≡ flip itraverse_

When you don't need access to the index then `for_` is more flexible in what it accepts.

    for_ a ≡ ifor_ a . const

imapM_ :: (FoldableWithIndex i t, Monad m) => (i -> a -> m b) -> t a -> m () #

Run monadic actions for each target of an `IndexedFold` or `IndexedTraversal` with access to the index, discarding the results.

When you don't need access to the index then `mapMOf_` is more flexible in what it accepts.

    mapM_ ≡ imapM . const

iforM_ :: (FoldableWithIndex i t, Monad m) => t a -> (i -> a -> m b) -> m () #

Run monadic actions for each target of an `IndexedFold` or `IndexedTraversal` with access to the index, discarding the results (with the arguments flipped).

    iforM_ ≡ flip imapM_

When you don't need access to the index then `forM_` is more flexible in what it accepts.

    forM_ a ≡ iforM a . const

iconcatMap :: FoldableWithIndex i f => (i -> a -> [b]) -> f a -> [b] #

Concatenate the results of a function of the elements of an indexed container with access to the index.

When you don't need access to the index then `concatMap` is more flexible in what it accepts.

    concatMap ≡ iconcatMap . const
    iconcatMap ≡ ifoldMap

ifind :: FoldableWithIndex i f => (i -> a -> Bool) -> f a -> Maybe (i, a) #

Searches a container with a predicate that is also supplied the index, returning the left-most element of the structure matching the predicate, or `Nothing` if there is no such element.

When you don't need access to the index then `find` is more flexible in what it accepts.

    find ≡ ifind . const

ifoldrM :: (FoldableWithIndex i f, Monad m) => (i -> a -> b -> m b) -> b -> f a -> m b #

Monadic fold right over the elements of a structure with an index.

When you don't need access to the index then `foldrM` is more flexible in what it accepts.

    foldrM ≡ ifoldrM . const

ifoldlM :: (FoldableWithIndex i f, Monad m) => (i -> b -> a -> m b) -> b -> f a -> m b #

Monadic fold over the elements of a structure with an index, associating to the left.

When you don't need access to the index then `foldlM` is more flexible in what it accepts.

    foldlM ≡ ifoldlM . const

itoList :: FoldableWithIndex i f => f a -> [(i, a)] #

Extract the key-value pairs from a structure.

When you don't need access to the indices in the result, then `toList` is more flexible in what it accepts.

    toList ≡ map snd . itoList