Portability | rank 2 types, MPTCs, TFs, flexible |
---|---|

Stability | provisional |

Maintainer | Edward Kmett <ekmett@gmail.com> |

Safe Haskell | Safe-Infered |

- type IndexedFold i a c = forall k f b d. (Indexed i k, Applicative f, Gettable f) => k (c -> f d) (a -> f b)
- ifoldMapOf :: IndexedGetting i m a b c d -> (i -> c -> m) -> a -> m
- ifoldrOf :: IndexedGetting i (Endo e) a b c d -> (i -> c -> e -> e) -> e -> a -> e
- ifoldlOf :: IndexedGetting i (Dual (Endo e)) a b c d -> (i -> e -> c -> e) -> e -> a -> e
- ianyOf :: IndexedGetting i Any a b c d -> (i -> c -> Bool) -> a -> Bool
- iallOf :: IndexedGetting i All a b c d -> (i -> c -> Bool) -> a -> Bool
- itraverseOf_ :: Functor f => IndexedGetting i (Traversed f) a b c d -> (i -> c -> f e) -> a -> f ()
- iforOf_ :: Functor f => IndexedGetting i (Traversed f) a b c d -> a -> (i -> c -> f e) -> f ()
- imapMOf_ :: Monad m => IndexedGetting i (Sequenced m) a b c d -> (i -> c -> m e) -> a -> m ()
- iforMOf_ :: Monad m => IndexedGetting i (Sequenced m) a b c d -> a -> (i -> c -> m e) -> m ()
- iconcatMapOf :: IndexedGetting i [e] a b c d -> (i -> c -> [e]) -> a -> [e]
- ifindOf :: IndexedGetting i (First (i, c)) a b c d -> (i -> c -> Bool) -> a -> Maybe (i, c)
- ifoldrOf' :: IndexedGetting i (Dual (Endo (e -> e))) a b c d -> (i -> c -> e -> e) -> e -> a -> e
- ifoldlOf' :: IndexedGetting i (Endo (e -> e)) a b c d -> (i -> e -> c -> e) -> e -> a -> e
- ifoldrMOf :: Monad m => IndexedGetting i (Dual (Endo (e -> m e))) a b c d -> (i -> c -> e -> m e) -> e -> a -> m e
- ifoldlMOf :: Monad m => IndexedGetting i (Endo (e -> m e)) a b c d -> (i -> e -> c -> m e) -> e -> a -> m e
- itoListOf :: IndexedGetting i [(i, c)] a b c d -> a -> [(i, c)]

# Indexed Folds

type IndexedFold i a c = forall k f b d. (Indexed i k, Applicative f, Gettable f) => k (c -> f d) (a -> f b)Source

Every `IndexedFold`

is a valid `Fold`

.

ifoldMapOf :: IndexedGetting i m a b c d -> (i -> c -> m) -> a -> mSource

Fold an `IndexedFold`

or `IndexedTraversal`

by mapping indices and values to an arbitrary `Monoid`

with access
to the index `i`

.

When you don't need access to the index then `foldMapOf`

is more flexible in what it accepts.

`foldMapOf`

l =`ifoldMapOf`

l .`const`

ifoldMapOf :: IndexedGetter i a c -> (i -> c -> m) -> a -> m ifoldMapOf :: Monoid m => IndexedFold i a c -> (i -> c -> m) -> a -> m ifoldMapOf :: IndexedLens i a b c d -> (i -> c -> m) -> a -> m ifoldMapOf :: Monoid m => IndexedTraversal i a b c d -> (i -> c -> m) -> a -> m

ifoldrOf :: IndexedGetting i (Endo e) a b c d -> (i -> c -> e -> e) -> e -> a -> eSource

Right-associative fold of parts of a structure that are viewed through an `IndexedFold`

or `IndexedTraversal`

with
access to the index `i`

.

When you don't need access to the index then `foldrOf`

is more flexible in what it accepts.

`foldrOf`

l =`ifoldrOf`

l .`const`

ifoldrOf :: IndexedGetter i a c -> (i -> c -> e -> e) -> e -> a -> e ifoldrOf :: IndexedFold i a c -> (i -> c -> e -> e) -> e -> a -> e ifoldrOf :: IndexedLens i a b c d -> (i -> c -> e -> e) -> e -> a -> e ifoldrOf :: IndexedTraversal i a b c d -> (i -> c -> e -> e) -> e -> a -> e

ifoldlOf :: IndexedGetting i (Dual (Endo e)) a b c d -> (i -> e -> c -> e) -> e -> a -> eSource

Left-associative fold of the parts of a structure that are viewed through an `IndexedFold`

or `IndexedTraversal`

with
access to the index `i`

.

When you don't need access to the index then `foldlOf`

is more flexible in what it accepts.

`foldlOf`

l =`ifoldlOf`

l .`const`

ifoldlOf :: IndexedGetter i a c -> (i -> e -> c -> e) -> e -> a -> e ifoldlOf :: IndexedFold i a c -> (i -> e -> c -> e) -> e -> a -> e ifoldlOf :: IndexedLens i a b c d -> (i -> e -> c -> e) -> e -> a -> e ifoldlOf :: IndexedTraversal i a b c d -> (i -> e -> c -> e) -> e -> a -> e

ianyOf :: IndexedGetting i Any a b c d -> (i -> c -> Bool) -> a -> BoolSource

Return whether or not any element viewed through an `IndexedFold`

or `IndexedTraversal`

satisfy a predicate, with access to the index `i`

.

When you don't need access to the index then `anyOf`

is more flexible in what it accepts.

`anyOf`

l =`ianyOf`

l .`const`

ianyOf :: IndexedGetter i a c -> (i -> c -> Bool) -> a -> Bool ianyOf :: IndexedFold i a c -> (i -> c -> Bool) -> a -> Bool ianyOf :: IndexedLens i a b c d -> (i -> c -> Bool) -> a -> Bool ianyOf :: IndexedTraversal i a b c d -> (i -> c -> Bool) -> a -> Bool

iallOf :: IndexedGetting i All a b c d -> (i -> c -> Bool) -> a -> BoolSource

Return whether or not all elements viewed through an `IndexedFold`

or `IndexedTraversal`

satisfy a predicate, with access to the index `i`

.

When you don't need access to the index then `allOf`

is more flexible in what it accepts.

`allOf`

l =`iallOf`

l .`const`

iallOf :: IndexedGetter i a c -> (i -> c -> Bool) -> a -> Bool iallOf :: IndexedFold i a c -> (i -> c -> Bool) -> a -> Bool iallOf :: IndexedLens i a b c d -> (i -> c -> Bool) -> a -> Bool iallOf :: IndexedTraversal i a b c d -> (i -> c -> Bool) -> a -> Bool

itraverseOf_ :: Functor f => IndexedGetting i (Traversed f) a b c d -> (i -> c -> f e) -> a -> f ()Source

Traverse the targets of an `IndexedFold`

or `IndexedTraversal`

with access to the index `i`

, discarding the results.

When you don't need access to the index then `traverseOf_`

is more flexible in what it accepts.

`traverseOf_`

l =`itraverseOf`

l .`const`

itraverseOf_ :: Functor f => IndexedGetter i a c -> (i -> c -> f e) -> a -> f () itraverseOf_ :: Applicative f => IndexedFold i a c -> (i -> c -> f e) -> a -> f () itraverseOf_ :: Functor f => IndexedLens i a b c d -> (i -> c -> f e) -> a -> f () itraverseOf_ :: Applicative f => IndexedTraversal i a b c d -> (i -> c -> f e) -> a -> f ()

iforOf_ :: Functor f => IndexedGetting i (Traversed f) a b c d -> a -> (i -> c -> f e) -> f ()Source

Traverse the targets of an `IndexedFold`

or `IndexedTraversal`

with access to the index, discarding the results
(with the arguments flipped).

`iforOf_`

=`flip`

.`itraverseOf_`

When you don't need access to the index then `forOf_`

is more flexible in what it accepts.

`forOf_`

l a =`iforOf`

l a .`const`

iforOf_ :: Functor f => IndexedGetter i a c -> a -> (i -> c -> f e) -> f () iforOf_ :: Applicative f => IndexedFold i a c -> a -> (i -> c -> f e) -> f () iforOf_ :: Functor f => IndexedLens i a b c d -> a -> (i -> c -> f e) -> f () iforOf_ :: Applicative f => IndexedTraversal i a b c d -> a -> (i -> c -> f e) -> f ()

imapMOf_ :: Monad m => IndexedGetting i (Sequenced m) a b c d -> (i -> c -> m e) -> a -> m ()Source

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.

`mapMOf_`

l =`imapMOf`

l .`const`

imapMOf_ :: Monad m => IndexedGetter i a c -> (i -> c -> m e) -> a -> m () imapMOf_ :: Monad m => IndexedFold i a c -> (i -> c -> m e) -> a -> m () imapMOf_ :: Monad m => IndexedLens i a b c d -> (i -> c -> m e) -> a -> m () imapMOf_ :: Monad m => IndexedTraversal i a b c d -> (i -> c -> m e) -> a -> m ()

iforMOf_ :: Monad m => IndexedGetting i (Sequenced m) a b c d -> a -> (i -> c -> m e) -> m ()Source

Run monadic actions for each target of an `IndexedFold`

or `IndexedTraversal`

with access to the index,
discarding the results (with the arguments flipped).

`iforMOf_`

=`flip`

.`imapMOf_`

When you don't need access to the index then `forMOf_`

is more flexible in what it accepts.

`forMOf_`

l a =`iforMOf`

l a .`const`

iforMOf_ :: Monad m => IndexedGetter i a c -> a -> (i -> c -> m e) -> m () iforMOf_ :: Monad m => IndexedFold i a c -> a -> (i -> c -> m e) -> m () iforMOf_ :: Monad m => IndexedLens i a b c d -> a -> (i -> c -> m e) -> m () iforMOf_ :: Monad m => IndexedTraversal i a b c d -> a -> (i -> c -> m e) -> m ()

iconcatMapOf :: IndexedGetting i [e] a b c d -> (i -> c -> [e]) -> a -> [e]Source

Concatenate the results of a function of the elements of an `IndexedFold`

or `IndexedTraversal`

with access to the index.

When you don't need access to the index then `concatMapOf_`

is more flexible in what it accepts.

`concatMapOf_`

l =`iconcatMapMOf`

l .`const`

iconcatMapOf :: IndexedGetter i a c -> (i -> c -> [e]) -> a -> [e] iconcatMapOf :: IndexedFold i a c -> (i -> c -> [e]) -> a -> [e] iconcatMapOf :: IndexedLens i a b c d -> (i -> c -> [e]) -> a -> [e] iconcatMapOf :: IndexedTraversal i a b c d -> (i -> c -> [e]) -> a -> [e]

ifindOf :: IndexedGetting i (First (i, c)) a b c d -> (i -> c -> Bool) -> a -> Maybe (i, c)Source

The `findOf`

function takes an `IndexedFold`

or `IndexedTraversal`

, a predicate that is also
supplied the index, a structure and returns 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 `findOf`

is more flexible in what it accepts.

`findOf`

l =`ifoldOf`

l .`const`

ifindOf :: IndexedGetter a c -> (i -> c -> Bool) -> a -> Maybe (i, c) ifindOf :: IndexedFold a c -> (i -> c -> Bool) -> a -> Maybe (i, c) ifindOf :: IndexedLens a b c d -> (i -> c -> Bool) -> a -> Maybe (i, c) ifindOf :: IndexedTraversal a b c d -> (i -> c -> Bool) -> a -> Maybe (i, c)

ifoldrOf' :: IndexedGetting i (Dual (Endo (e -> e))) a b c d -> (i -> c -> e -> e) -> e -> a -> eSource

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

When you don't need access to the index then `foldrOf'`

is more flexible in what it accepts.

`foldrOf'`

l =`ifoldrOf'`

l .`const`

ifoldrOf' :: IndexedGetter i a c -> (i -> c -> e -> e) -> e -> a -> e ifoldrOf' :: IndexedFold i a c -> (i -> c -> e -> e) -> e -> a -> e ifoldrOf' :: IndexedLens i a b c d -> (i -> c -> e -> e) -> e -> a -> e ifoldrOf' :: IndexedTraversal i a b c d -> (i -> c -> e -> e) -> e -> a -> e

ifoldlOf' :: IndexedGetting i (Endo (e -> e)) a b c d -> (i -> e -> c -> e) -> e -> a -> eSource

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.

`foldlOf'`

l =`ifoldlOf'`

l .`const`

ifoldlOf' :: IndexedGetter i a c -> (i -> e -> c -> e) -> e -> a -> e ifoldlOf' :: IndexedFold i a c -> (i -> e -> c -> e) -> e -> a -> e ifoldlOf' :: IndexedLens i a b c d -> (i -> e -> c -> e) -> e -> a -> e ifoldlOf' :: IndexedTraversal i a b c d -> (i -> e -> c -> e) -> e -> a -> e

ifoldrMOf :: Monad m => IndexedGetting i (Dual (Endo (e -> m e))) a b c d -> (i -> c -> e -> m e) -> e -> a -> m eSource

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

When you don't need access to the index then `foldrMOf`

is more flexible in what it accepts.

`foldrMOf`

l =`ifoldrMOf`

l .`const`

ifoldrMOf :: Monad m => IndexedGetter i a c -> (i -> c -> e -> m e) -> e -> a -> e ifoldrMOf :: Monad m => IndexedFold i a c -> (i -> c -> e -> m e) -> e -> a -> e ifoldrMOf :: Monad m => IndexedLens i a b c d -> (i -> c -> e -> m e) -> e -> a -> e ifoldrMOf :: Monad m => IndexedTraversal i a b c d -> (i -> c -> e -> m e) -> e -> a -> e

ifoldlMOf :: Monad m => IndexedGetting i (Endo (e -> m e)) a b c d -> (i -> e -> c -> m e) -> e -> a -> m eSource

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 `foldlMOf`

is more flexible in what it accepts.

`foldlMOf`

l =`ifoldlMOf`

l .`const`

ifoldlOf' :: Monad m => IndexedGetter i a c -> (i -> e -> c -> m e) -> e -> a -> e ifoldlOf' :: Monad m => IndexedFold i a c -> (i -> e -> c -> m e) -> e -> a -> e ifoldlOf' :: Monad m => IndexedLens i a b c d -> (i -> e -> c -> m e) -> e -> a -> e ifoldlOf' :: Monad m => IndexedTraversal i a b c d -> (i -> e -> c -> m e) -> e -> a -> e

itoListOf :: IndexedGetting i [(i, c)] a b c d -> a -> [(i, c)]Source

Extract the key-value pairs from a structure.

When you don't need access to the indices, then `toListOf`

is more flexible in what it accepts.

`toListOf`

l =`map`

`fst`

.`itoListOf`

l

itoListOf :: IndexedGetter i a c -> a -> [(i,c)] itoListOf :: IndexedFold i a c -> a -> [(i,c)] itoListOf :: IndexedLens i a b c d -> a -> [(i,c)] itoListOf :: IndexedTraversal i a b c d -> a -> [(i,c)]