| Portability | rank 2 types, MPTCs, TFs, flexible | 
|---|---|
| Stability | provisional | 
| Maintainer | Edward Kmett <ekmett@gmail.com> | 
| Safe Haskell | Safe-Infered | 
Control.Lens.IndexedTraversal
Contents
Description
- type IndexedTraversal i a b c d = forall f k. (Indexed i k, Applicative f) => k (c -> f d) (a -> f b)
- itraverseOf :: Overloaded (Index i) f a b c d -> (i -> c -> f d) -> a -> f b
- iforOf :: Overloaded (Index i) f a b c d -> a -> (i -> c -> f d) -> f b
- imapMOf :: Overloaded (Index i) (WrappedMonad m) a b c d -> (i -> c -> m d) -> a -> m b
- iforMOf :: Overloaded (Index i) (WrappedMonad m) a b c d -> a -> (i -> c -> m d) -> m b
- imapAccumROf :: Overloaded (Index i) (State s) a b c d -> (i -> s -> c -> (s, d)) -> s -> a -> (s, b)
- imapAccumLOf :: Overloaded (Index i) (Backwards (State s)) a b c d -> (i -> s -> c -> (s, d)) -> s -> a -> (s, b)
- type SimpleIndexedTraversal i a b = IndexedTraversal i a a b b
Indexed Traversals
type IndexedTraversal i a b c d = forall f k. (Indexed i k, Applicative f) => k (c -> f d) (a -> f b)Source
Every indexed traversal is a valid Traversal or IndexedFold.
The Indexed constraint is used to allow an IndexedTraversal to be used directly as a Traversal.
The Traversal laws are still required to hold.
itraverseOf :: Overloaded (Index i) f a b c d -> (i -> c -> f d) -> a -> f bSource
Traversal with an index.
NB: When you don't need access to the index then you can just apply your IndexedTraversal
 directly as a function!
itraverseOf=withIndextraverseOf=itraverseOf.const=id
itraverseOf ::IndexedLensi a b c d -> (i -> c -> f d) -> a -> f b itraverseOf ::IndexedTraversali a b c d -> (i -> c -> f d) -> a -> f b
iforOf :: Overloaded (Index i) f a b c d -> a -> (i -> c -> f d) -> f bSource
Traverse with an index (and the arguments flipped)
forOfl a =iforOfl a .const
iforOf=flip.itraverseOf
iforOf ::IndexedLensi a b c d -> a -> (i -> c -> f d) -> f b iforOf ::IndexedTraversali a b c d -> a -> (i -> c -> f d) -> f b
imapMOf :: Overloaded (Index i) (WrappedMonad m) a b c d -> (i -> c -> m d) -> a -> m bSource
Map each element of a structure targeted by a lens to a monadic action, evaluate these actions from left to right, and collect the results, with access its position.
When you don't need access to the index mapMOf is more liberal in what it can accept.
mapMOf=imapMOf.const
imapMOf ::Monadm =>IndexedLensi a b c d -> (i -> c -> m d) -> a -> m b imapMOf ::Monadm =>IndexedTraversali a b c d -> (i -> c -> m d) -> a -> m b
iforMOf :: Overloaded (Index i) (WrappedMonad m) a b c d -> a -> (i -> c -> m d) -> m bSource
Map each element of a structure targeted by a lens to a monadic action, evaluate these actions from left to right, and collect the results, with access its position (and the arguments flipped).
forMOfl a =iforMOfl a .constiforMOf=flip.imapMOf
iforMOf ::Monadm =>IndexedLensi a b c d -> a -> (i -> c -> m d) -> m b iforMOf ::Monadm =>IndexedTraversali a b c d -> a -> (i -> c -> m d) -> m b
imapAccumROf :: Overloaded (Index i) (State s) a b c d -> (i -> s -> c -> (s, d)) -> s -> a -> (s, b)Source
Generalizes mapAccumR to an arbitrary IndexedTraversal with access to the index.
imapAccumROf accumulates state from right to left.
mapAccumROfl =imapAccumROfl .const
imapAccumROf ::IndexedLensi a b c d -> (i -> s -> c -> (s, d)) -> s -> a -> (s, b) imapAccumROf ::IndexedTraversali a b c d -> (i -> s -> c -> (s, d)) -> s -> a -> (s, b)
imapAccumLOf :: Overloaded (Index i) (Backwards (State s)) a b c d -> (i -> s -> c -> (s, d)) -> s -> a -> (s, b)Source
Generalizes mapAccumL to an arbitrary IndexedTraversal with access to the index.
imapAccumLOf accumulates state from left to right.
mapAccumLOfl =imapAccumLOfl .const
imapAccumLOf ::IndexedLensi a b c d -> (i -> s -> c -> (s, d)) -> s -> a -> (s, b) imapAccumLOf ::IndexedTraversali a b c d -> (i -> s -> c -> (s, d)) -> s -> a -> (s, b)
Simple
type SimpleIndexedTraversal i a b = IndexedTraversal i a a b bSource
typeSimpleIndexedTraversali =Simple(IndexedTraversali)