/
Control-Lens-WithIndex.html
105 lines (105 loc) · 54.8 KB
/
Control-Lens-WithIndex.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Control.Lens.WithIndex</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
window.onload = function () {pageLoad();setSynopsis("mini_Control-Lens-WithIndex.html");};
//]]>
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="src/Control-Lens-WithIndex.html">Source</a></li><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">lens-2.6: Lenses, Folds and Traversals</p></div><div id="content"><div id="module-header"><table class="info"><tr><th>Portability</th><td>Rank2Types</td></tr><tr><th>Stability</th><td>provisional</td></tr><tr><th>Maintainer</th><td>Edward Kmett <ekmett@gmail.com></td></tr><tr><th>Safe Haskell</th><td>Safe-Infered</td></tr></table><p class="caption">Control.Lens.WithIndex</p></div><div id="table-of-contents"><p class="caption">Contents</p><ul><li><a href="#g:1">Indexed Functors
</a></li><li><a href="#g:2">Indexed Foldables
</a><ul><li><a href="#g:3">Indexed Foldable Combinators
</a></li></ul></li><li><a href="#g:4">Converting to Folds
</a></li><li><a href="#g:5">Indexed Traversables
</a></li><li><a href="#g:6">Indexed Traversable Combinators
</a></li></ul></div><div id="description"><p class="caption">Description</p><div class="doc"><p>(These need to be defined together for <code>DefaultSignatures</code> to work.)
</p></div></div><div id="synopsis"><p id="control.syn" class="caption expander" onclick="toggleSection('syn')">Synopsis</p><ul id="section.syn" class="hide" onclick="toggleSection('syn')"><li class="src short"><span class="keyword">class</span> <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Control-Monad.html#t:Functor">Functor</a> f => <a href="#t:FunctorWithIndex">FunctorWithIndex</a> i f | f -> i <span class="keyword">where</span><ul class="subs"><li><a href="#v:imap">imap</a> :: (i -> a -> b) -> f a -> f b</li></ul></li><li class="src short"><a href="#v:imapped">imapped</a> :: <a href="Control-Lens-WithIndex.html#t:FunctorWithIndex">FunctorWithIndex</a> i f => <a href="Control-Lens-IndexedSetter.html#t:IndexedSetter">IndexedSetter</a> i (f a) (f b) a b</li><li class="src short"><span class="keyword">class</span> <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Foldable.html#t:Foldable">Foldable</a> f => <a href="#t:FoldableWithIndex">FoldableWithIndex</a> i f | f -> i <span class="keyword">where</span><ul class="subs"><li><a href="#v:ifoldMap">ifoldMap</a> :: <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Monoid.html#t:Monoid">Monoid</a> m => (i -> a -> m) -> f a -> m</li><li><a href="#v:ifoldr">ifoldr</a> :: (i -> a -> b -> b) -> b -> f a -> b</li><li><a href="#v:ifoldl">ifoldl</a> :: (i -> b -> a -> b) -> b -> f a -> b</li><li><a href="#v:ifoldr-39-">ifoldr'</a> :: (i -> a -> b -> b) -> b -> f a -> b</li><li><a href="#v:ifoldl-39-">ifoldl'</a> :: (i -> b -> a -> b) -> b -> f a -> b</li></ul></li><li class="src short"><a href="#v:ifolded">ifolded</a> :: <a href="Control-Lens-WithIndex.html#t:FoldableWithIndex">FoldableWithIndex</a> i f => <a href="Control-Lens-IndexedFold.html#t:IndexedFold">IndexedFold</a> i (f a) a</li><li class="src short"><a href="#v:ifolding">ifolding</a> :: <a href="Control-Lens-WithIndex.html#t:FoldableWithIndex">FoldableWithIndex</a> i f => (a -> f c) -> <a href="Control-Lens-IndexedFold.html#t:IndexedFold">IndexedFold</a> i a c</li><li class="src short"><a href="#v:iany">iany</a> :: <a href="Control-Lens-WithIndex.html#t:FoldableWithIndex">FoldableWithIndex</a> i f => (i -> a -> <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Bool.html#t:Bool">Bool</a>) -> f a -> <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:iall">iall</a> :: <a href="Control-Lens-WithIndex.html#t:FoldableWithIndex">FoldableWithIndex</a> i f => (i -> a -> <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Bool.html#t:Bool">Bool</a>) -> f a -> <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:itraverse_">itraverse_</a> :: (<a href="Control-Lens-WithIndex.html#t:FoldableWithIndex">FoldableWithIndex</a> i t, <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Control-Applicative.html#t:Applicative">Applicative</a> f) => (i -> a -> f b) -> t a -> f <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a></li><li class="src short"><a href="#v:ifor_">ifor_</a> :: (<a href="Control-Lens-WithIndex.html#t:FoldableWithIndex">FoldableWithIndex</a> i t, <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Control-Applicative.html#t:Applicative">Applicative</a> f) => t a -> (i -> a -> f b) -> f <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a></li><li class="src short"><a href="#v:imapM_">imapM_</a> :: (<a href="Control-Lens-WithIndex.html#t:FoldableWithIndex">FoldableWithIndex</a> i t, <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Control-Monad.html#t:Monad">Monad</a> m) => (i -> a -> m b) -> t a -> m <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a></li><li class="src short"><a href="#v:iforM_">iforM_</a> :: (<a href="Control-Lens-WithIndex.html#t:FoldableWithIndex">FoldableWithIndex</a> i t, <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Control-Monad.html#t:Monad">Monad</a> m) => t a -> (i -> a -> m b) -> m <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a></li><li class="src short"><a href="#v:iconcatMap">iconcatMap</a> :: <a href="Control-Lens-WithIndex.html#t:FoldableWithIndex">FoldableWithIndex</a> i f => (i -> a -> [b]) -> f a -> [b]</li><li class="src short"><a href="#v:ifind">ifind</a> :: <a href="Control-Lens-WithIndex.html#t:FoldableWithIndex">FoldableWithIndex</a> i f => (i -> a -> <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Bool.html#t:Bool">Bool</a>) -> f a -> <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Maybe.html#t:Maybe">Maybe</a> (i, a)</li><li class="src short"><a href="#v:ifoldrM">ifoldrM</a> :: (<a href="Control-Lens-WithIndex.html#t:FoldableWithIndex">FoldableWithIndex</a> i f, <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Control-Monad.html#t:Monad">Monad</a> m) => (i -> a -> b -> m b) -> b -> f a -> m b</li><li class="src short"><a href="#v:ifoldlM">ifoldlM</a> :: (<a href="Control-Lens-WithIndex.html#t:FoldableWithIndex">FoldableWithIndex</a> i f, <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Control-Monad.html#t:Monad">Monad</a> m) => (i -> b -> a -> m b) -> b -> f a -> m b</li><li class="src short"><a href="#v:itoList">itoList</a> :: <a href="Control-Lens-WithIndex.html#t:FoldableWithIndex">FoldableWithIndex</a> i f => f a -> [(i, a)]</li><li class="src short"><a href="#v:withIndices">withIndices</a> :: <a href="Control-Lens-WithIndex.html#t:FoldableWithIndex">FoldableWithIndex</a> i f => <a href="Control-Lens-Fold.html#t:Fold">Fold</a> (f a) (i, a)</li><li class="src short"><a href="#v:indices">indices</a> :: <a href="Control-Lens-WithIndex.html#t:FoldableWithIndex">FoldableWithIndex</a> i f => <a href="Control-Lens-Fold.html#t:Fold">Fold</a> (f a) i</li><li class="src short"><span class="keyword">class</span> (<a href="Control-Lens-WithIndex.html#t:FunctorWithIndex">FunctorWithIndex</a> i t, <a href="Control-Lens-WithIndex.html#t:FoldableWithIndex">FoldableWithIndex</a> i t, <a href="Control-Lens-Traversal.html#t:Traversable">Traversable</a> t) => <a href="#t:TraversableWithIndex">TraversableWithIndex</a> i t | t -> i <span class="keyword">where</span><ul class="subs"><li><a href="#v:itraverse">itraverse</a> :: <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Control-Applicative.html#t:Applicative">Applicative</a> f => (i -> a -> f b) -> t a -> f (t b)</li></ul></li><li class="src short"><a href="#v:itraversed">itraversed</a> :: <a href="Control-Lens-WithIndex.html#t:TraversableWithIndex">TraversableWithIndex</a> i f => <a href="Control-Lens-IndexedTraversal.html#t:IndexedTraversal">IndexedTraversal</a> i (f a) (f b) a b</li><li class="src short"><a href="#v:ifor">ifor</a> :: (<a href="Control-Lens-WithIndex.html#t:TraversableWithIndex">TraversableWithIndex</a> i t, <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Control-Applicative.html#t:Applicative">Applicative</a> f) => t a -> (i -> a -> f b) -> f (t b)</li><li class="src short"><a href="#v:imapM">imapM</a> :: (<a href="Control-Lens-WithIndex.html#t:TraversableWithIndex">TraversableWithIndex</a> i t, <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Control-Monad.html#t:Monad">Monad</a> m) => (i -> a -> m b) -> t a -> m (t b)</li><li class="src short"><a href="#v:iforM">iforM</a> :: (<a href="Control-Lens-WithIndex.html#t:TraversableWithIndex">TraversableWithIndex</a> i t, <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Control-Monad.html#t:Monad">Monad</a> m) => t a -> (i -> a -> m b) -> m (t b)</li><li class="src short"><a href="#v:imapAccumR">imapAccumR</a> :: <a href="Control-Lens-WithIndex.html#t:TraversableWithIndex">TraversableWithIndex</a> i t => (i -> s -> a -> (s, b)) -> s -> t a -> (s, t b)</li><li class="src short"><a href="#v:imapAccumL">imapAccumL</a> :: <a href="Control-Lens-WithIndex.html#t:TraversableWithIndex">TraversableWithIndex</a> i t => (i -> s -> a -> (s, b)) -> s -> t a -> (s, t b)</li><li class="src short"><a href="#v:iwhere">iwhere</a> :: <a href="Control-Lens-WithIndex.html#t:TraversableWithIndex">TraversableWithIndex</a> i t => (i -> <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Bool.html#t:Bool">Bool</a>) -> <a href="Control-Lens-IndexedTraversal.html#t:SimpleIndexedTraversal">SimpleIndexedTraversal</a> i (t a) a</li></ul></div><div id="interface"><h1 id="g:1">Indexed Functors
</h1><div class="top"><p class="src"><span class="keyword">class</span> <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Control-Monad.html#t:Functor">Functor</a> f => <a name="t:FunctorWithIndex" class="def">FunctorWithIndex</a> i f | f -> i <span class="keyword">where</span><a href="src/Control-Lens-WithIndex.html#FunctorWithIndex" class="link">Source</a></p><div class="doc"><p>A <code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Control-Monad.html#t:Functor">Functor</a></code> with an additional index.
</p><p>Instances must satisfy a modified form of the <code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Control-Monad.html#t:Functor">Functor</a></code> laws:
</p><pre>
<code><a href="Control-Lens-WithIndex.html#v:imap">imap</a></code> f . <code><a href="Control-Lens-WithIndex.html#v:imap">imap</a></code> g = <code><a href="Control-Lens-WithIndex.html#v:imap">imap</a></code> (i -> f i . g i)
<code><a href="Control-Lens-WithIndex.html#v:imap">imap</a></code> (_ a -> a) = <code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Prelude.html#v:id">id</a></code>
</pre></div><div class="subs methods"><p class="caption">Methods</p><p class="src"><a name="v:imap" class="def">imap</a> :: (i -> a -> b) -> f a -> f b<a href="src/Control-Lens-WithIndex.html#imap" class="link">Source</a></p><div class="doc"><p>Map with access to the index.
</p></div></div><div class="subs instances"><p id="control.i:FunctorWithIndex" class="caption collapser" onclick="toggleSection('i:FunctorWithIndex')">Instances</p><div id="section.i:FunctorWithIndex" class="show"><table><tr><td class="src"><a href="Control-Lens-WithIndex.html#t:FunctorWithIndex">FunctorWithIndex</a> <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Int.html#t:Int">Int</a> []</td><td class="doc"><p>The position in the list is available as the index.
</p></td></tr><tr><td class="src"><a href="Control-Lens-WithIndex.html#t:FunctorWithIndex">FunctorWithIndex</a> <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Int.html#t:Int">Int</a> <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/containers-0.4.2.1/Data-Sequence.html#t:Seq">Seq</a></td><td class="doc"><p>The position in the sequence is available as the index.
</p></td></tr><tr><td class="src"><a href="Control-Lens-WithIndex.html#t:FunctorWithIndex">FunctorWithIndex</a> <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Int.html#t:Int">Int</a> <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/containers-0.4.2.1/Data-IntMap.html#t:IntMap">IntMap</a></td><td class="doc empty"> </td></tr><tr><td class="src">(<a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Eq.html#t:Eq">Eq</a> k, Hashable k) => <a href="Control-Lens-WithIndex.html#t:FunctorWithIndex">FunctorWithIndex</a> k (HashMap k)</td><td class="doc empty"> </td></tr><tr><td class="src"><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Ord.html#t:Ord">Ord</a> k => <a href="Control-Lens-WithIndex.html#t:FunctorWithIndex">FunctorWithIndex</a> k (<a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/containers-0.4.2.1/Data-Map.html#t:Map">Map</a> k)</td><td class="doc empty"> </td></tr></table></div></div></div><div class="top"><p class="src"><a name="v:imapped" class="def">imapped</a> :: <a href="Control-Lens-WithIndex.html#t:FunctorWithIndex">FunctorWithIndex</a> i f => <a href="Control-Lens-IndexedSetter.html#t:IndexedSetter">IndexedSetter</a> i (f a) (f b) a b<a href="src/Control-Lens-WithIndex.html#imapped" class="link">Source</a></p><div class="doc"><p>The <code><a href="Control-Lens-IndexedSetter.html#t:IndexedSetter">IndexedSetter</a></code> for a <code><a href="Control-Lens-WithIndex.html#t:FunctorWithIndex">FunctorWithIndex</a></code>.
</p><p>If you don't need access to the index, then <code>mapped</code> is more flexible in what it accepts.
</p></div></div><h1 id="g:2">Indexed Foldables
</h1><div class="top"><p class="src"><span class="keyword">class</span> <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Foldable.html#t:Foldable">Foldable</a> f => <a name="t:FoldableWithIndex" class="def">FoldableWithIndex</a> i f | f -> i <span class="keyword">where</span><a href="src/Control-Lens-WithIndex.html#FoldableWithIndex" class="link">Source</a></p><div class="doc"><p>A container that supports folding with an additional index.
</p></div><div class="subs methods"><p class="caption">Methods</p><p class="src"><a name="v:ifoldMap" class="def">ifoldMap</a> :: <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Monoid.html#t:Monoid">Monoid</a> m => (i -> a -> m) -> f a -> m<a href="src/Control-Lens-WithIndex.html#ifoldMap" class="link">Source</a></p><div class="doc"><p>Fold a container by mapping value to an arbitrary <code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Monoid.html#t:Monoid">Monoid</a></code> with access to the index <code>i</code>.
</p><p>When you don't need access to the index then <code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Foldable.html#v:foldMap">foldMap</a></code> is more flexible in what it accepts.
</p><pre><code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Foldable.html#v:foldMap">foldMap</a></code> = <code><a href="Control-Lens-WithIndex.html#v:ifoldMap">ifoldMap</a></code> . <code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Prelude.html#v:const">const</a></code></pre></div><p class="src"><a name="v:ifoldr" class="def">ifoldr</a> :: (i -> a -> b -> b) -> b -> f a -> b<a href="src/Control-Lens-WithIndex.html#ifoldr" class="link">Source</a></p><div class="doc"><p>Right-associative fold of an indexed container with access to the index <code>i</code>.
</p><p>When you don't need access to the index then <code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Foldable.html#v:foldr">foldr</a></code> is more flexible in what it accepts.
</p><pre><code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Foldable.html#v:foldr">foldr</a></code> = <code><a href="Control-Lens-WithIndex.html#v:ifoldr">ifoldr</a></code> . <code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Prelude.html#v:const">const</a></code></pre></div><p class="src"><a name="v:ifoldl" class="def">ifoldl</a> :: (i -> b -> a -> b) -> b -> f a -> b<a href="src/Control-Lens-WithIndex.html#ifoldl" class="link">Source</a></p><div class="doc"><p>Left-associative fold of an indexed container with access to the index <code>i</code>.
</p><p>When you don't need access to the index then <code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/containers-0.4.2.1/Data-IntMap.html#v:foldl">foldl</a></code> is more flexible in what it accepts.
</p><pre><code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/containers-0.4.2.1/Data-IntMap.html#v:foldl">foldl</a></code> = <code><a href="Control-Lens-WithIndex.html#v:ifoldl">ifoldl</a></code> . <code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Prelude.html#v:const">const</a></code></pre></div><p class="src"><a name="v:ifoldr-39-" class="def">ifoldr'</a> :: (i -> a -> b -> b) -> b -> f a -> b<a href="src/Control-Lens-WithIndex.html#ifoldr%27" class="link">Source</a></p><div class="doc"><p><em>Strictly</em> fold right over the elements of a structure with access to the index <code>i</code>.
</p><p>When you don't need access to the index then <code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/containers-0.4.2.1/Data-Map.html#v:foldr-39-">foldr'</a></code> is more flexible in what it accepts.
</p><pre><code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/containers-0.4.2.1/Data-Map.html#v:foldr-39-">foldr'</a></code> = <code><a href="Control-Lens-WithIndex.html#v:ifoldr-39-">ifoldr'</a></code> . <code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Prelude.html#v:const">const</a></code></pre></div><p class="src"><a name="v:ifoldl-39-" class="def">ifoldl'</a> :: (i -> b -> a -> b) -> b -> f a -> b<a href="src/Control-Lens-WithIndex.html#ifoldl%27" class="link">Source</a></p><div class="doc"><p>Fold over the elements of a structure with an index, associating to the left, but <em>strictly</em>.
</p><p>When you don't need access to the index then <code><a href="Control-Lens-Fold.html#v:foldlOf-39-">foldlOf'</a></code> is more flexible in what it accepts.
</p><pre><code><a href="Control-Lens-Fold.html#v:foldlOf-39-">foldlOf'</a></code> l = <code><a href="Control-Lens-IndexedFold.html#v:ifoldlOf-39-">ifoldlOf'</a></code> l . <code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Prelude.html#v:const">const</a></code></pre><pre>
<code><a href="Control-Lens-IndexedFold.html#v:ifoldlOf-39-">ifoldlOf'</a></code> :: <code><a href="Control-Lens-IndexedGetter.html#t:IndexedGetter">IndexedGetter</a></code> i a c -> (i -> e -> c -> e) -> e -> a -> e
<code><a href="Control-Lens-IndexedFold.html#v:ifoldlOf-39-">ifoldlOf'</a></code> :: <code><a href="Control-Lens-IndexedFold.html#t:IndexedFold">IndexedFold</a></code> i a c -> (i -> e -> c -> e) -> e -> a -> e
<code><a href="Control-Lens-IndexedFold.html#v:ifoldlOf-39-">ifoldlOf'</a></code> :: <code><a href="Control-Lens-IndexedLens.html#t:SimpleIndexedLens">SimpleIndexedLens</a></code> i a c -> (i -> e -> c -> e) -> e -> a -> e
<code><a href="Control-Lens-IndexedFold.html#v:ifoldlOf-39-">ifoldlOf'</a></code> :: <code><a href="Control-Lens-IndexedTraversal.html#t:SimpleIndexedTraversal">SimpleIndexedTraversal</a></code> i a c -> (i -> e -> c -> e) -> e -> a -> e
</pre></div></div><div class="subs instances"><p id="control.i:FoldableWithIndex" class="caption collapser" onclick="toggleSection('i:FoldableWithIndex')">Instances</p><div id="section.i:FoldableWithIndex" class="show"><table><tr><td class="src"><a href="Control-Lens-WithIndex.html#t:FoldableWithIndex">FoldableWithIndex</a> <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Int.html#t:Int">Int</a> []</td><td class="doc empty"> </td></tr><tr><td class="src"><a href="Control-Lens-WithIndex.html#t:FoldableWithIndex">FoldableWithIndex</a> <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Int.html#t:Int">Int</a> <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/containers-0.4.2.1/Data-Sequence.html#t:Seq">Seq</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a href="Control-Lens-WithIndex.html#t:FoldableWithIndex">FoldableWithIndex</a> <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Int.html#t:Int">Int</a> <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/containers-0.4.2.1/Data-IntMap.html#t:IntMap">IntMap</a></td><td class="doc empty"> </td></tr><tr><td class="src">(<a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Eq.html#t:Eq">Eq</a> k, Hashable k) => <a href="Control-Lens-WithIndex.html#t:FoldableWithIndex">FoldableWithIndex</a> k (HashMap k)</td><td class="doc empty"> </td></tr><tr><td class="src"><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Ord.html#t:Ord">Ord</a> k => <a href="Control-Lens-WithIndex.html#t:FoldableWithIndex">FoldableWithIndex</a> k (<a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/containers-0.4.2.1/Data-Map.html#t:Map">Map</a> k)</td><td class="doc empty"> </td></tr></table></div></div></div><div class="top"><p class="src"><a name="v:ifolded" class="def">ifolded</a> :: <a href="Control-Lens-WithIndex.html#t:FoldableWithIndex">FoldableWithIndex</a> i f => <a href="Control-Lens-IndexedFold.html#t:IndexedFold">IndexedFold</a> i (f a) a<a href="src/Control-Lens-WithIndex.html#ifolded" class="link">Source</a></p><div class="doc"><p>The <code><a href="Control-Lens-IndexedFold.html#t:IndexedFold">IndexedFold</a></code> of a <code><a href="Control-Lens-WithIndex.html#t:FoldableWithIndex">FoldableWithIndex</a></code> container.
</p></div></div><div class="top"><p class="src"><a name="v:ifolding" class="def">ifolding</a> :: <a href="Control-Lens-WithIndex.html#t:FoldableWithIndex">FoldableWithIndex</a> i f => (a -> f c) -> <a href="Control-Lens-IndexedFold.html#t:IndexedFold">IndexedFold</a> i a c<a href="src/Control-Lens-WithIndex.html#ifolding" class="link">Source</a></p><div class="doc"><p>Obtain a <code><a href="Control-Lens-Fold.html#t:Fold">Fold</a></code> by lifting an operation that returns a foldable result.
</p><p>This can be useful to lift operations from <code>Data.List</code> and elsewhere into a <code><a href="Control-Lens-Fold.html#t:Fold">Fold</a></code>.
</p></div></div><h2 id="g:3">Indexed Foldable Combinators
</h2><div class="top"><p class="src"><a name="v:iany" class="def">iany</a> :: <a href="Control-Lens-WithIndex.html#t:FoldableWithIndex">FoldableWithIndex</a> i f => (i -> a -> <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Bool.html#t:Bool">Bool</a>) -> f a -> <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Bool.html#t:Bool">Bool</a><a href="src/Control-Lens-WithIndex.html#iany" class="link">Source</a></p><div class="doc"><p>Return whether or not any element in a container satisfies a predicate, with access to the index <code>i</code>.
</p><p>When you don't need access to the index then <code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Foldable.html#v:any">any</a></code> is more flexible in what it accepts.
</p><pre><code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Foldable.html#v:any">any</a></code> = <code><a href="Control-Lens-WithIndex.html#v:iany">iany</a></code> . <code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Prelude.html#v:const">const</a></code></pre></div></div><div class="top"><p class="src"><a name="v:iall" class="def">iall</a> :: <a href="Control-Lens-WithIndex.html#t:FoldableWithIndex">FoldableWithIndex</a> i f => (i -> a -> <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Bool.html#t:Bool">Bool</a>) -> f a -> <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Bool.html#t:Bool">Bool</a><a href="src/Control-Lens-WithIndex.html#iall" class="link">Source</a></p><div class="doc"><p>Return whether or not all elements in a container satisfy a predicate, with access to the index <code>i</code>.
</p><p>When you don't need access to the index then <code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Foldable.html#v:all">all</a></code> is more flexible in what it accepts.
</p><pre><code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Foldable.html#v:all">all</a></code> = <code><a href="Control-Lens-WithIndex.html#v:iall">iall</a></code> . <code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Prelude.html#v:const">const</a></code></pre></div></div><div class="top"><p class="src"><a name="v:itraverse_" class="def">itraverse_</a> :: (<a href="Control-Lens-WithIndex.html#t:FoldableWithIndex">FoldableWithIndex</a> i t, <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Control-Applicative.html#t:Applicative">Applicative</a> f) => (i -> a -> f b) -> t a -> f <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a><a href="src/Control-Lens-WithIndex.html#itraverse_" class="link">Source</a></p><div class="doc"><p>Traverse elements with access to the index <code>i</code>, discarding the results.
</p><p>When you don't need access to the index then <code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Foldable.html#v:traverse_">traverse_</a></code> is more flexible in what it accepts.
</p><pre><code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Foldable.html#v:traverse_">traverse_</a></code> l = <code><a href="Control-Lens-WithIndex.html#v:itraverse">itraverse</a></code> . <code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Prelude.html#v:const">const</a></code></pre></div></div><div class="top"><p class="src"><a name="v:ifor_" class="def">ifor_</a> :: (<a href="Control-Lens-WithIndex.html#t:FoldableWithIndex">FoldableWithIndex</a> i t, <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Control-Applicative.html#t:Applicative">Applicative</a> f) => t a -> (i -> a -> f b) -> f <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a><a href="src/Control-Lens-WithIndex.html#ifor_" class="link">Source</a></p><div class="doc"><p>Traverse elements with access to the index <code>i</code>, discarding the results (with the arguments flipped).
</p><pre><code><a href="Control-Lens-WithIndex.html#v:ifor_">ifor_</a></code> = <code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Prelude.html#v:flip">flip</a></code> <code><a href="Control-Lens-WithIndex.html#v:itraverse_">itraverse_</a></code></pre><p>When you don't need access to the index then <code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Foldable.html#v:for_">for_</a></code> is more flexible in what it accepts.
</p><pre><code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Foldable.html#v:for_">for_</a></code> a = <code><a href="Control-Lens-WithIndex.html#v:ifor_">ifor_</a></code> a . <code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Prelude.html#v:const">const</a></code></pre></div></div><div class="top"><p class="src"><a name="v:imapM_" class="def">imapM_</a> :: (<a href="Control-Lens-WithIndex.html#t:FoldableWithIndex">FoldableWithIndex</a> i t, <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Control-Monad.html#t:Monad">Monad</a> m) => (i -> a -> m b) -> t a -> m <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a><a href="src/Control-Lens-WithIndex.html#imapM_" class="link">Source</a></p><div class="doc"><p>Run monadic actions for each target of an <code><a href="Control-Lens-IndexedFold.html#t:IndexedFold">IndexedFold</a></code> or <code><a href="Control-Lens-IndexedTraversal.html#t:IndexedTraversal">IndexedTraversal</a></code> with access to the index,
discarding the results.
</p><p>When you don't need access to the index then <code><a href="Control-Lens-Fold.html#v:mapMOf_">mapMOf_</a></code> is more flexible in what it accepts.
</p><pre><code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Foldable.html#v:mapM_">mapM_</a></code> = <code><a href="Control-Lens-WithIndex.html#v:imapM">imapM</a></code> . <code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Prelude.html#v:const">const</a></code></pre></div></div><div class="top"><p class="src"><a name="v:iforM_" class="def">iforM_</a> :: (<a href="Control-Lens-WithIndex.html#t:FoldableWithIndex">FoldableWithIndex</a> i t, <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Control-Monad.html#t:Monad">Monad</a> m) => t a -> (i -> a -> m b) -> m <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a><a href="src/Control-Lens-WithIndex.html#iforM_" class="link">Source</a></p><div class="doc"><p>Run monadic actions for each target of an <code><a href="Control-Lens-IndexedFold.html#t:IndexedFold">IndexedFold</a></code> or <code><a href="Control-Lens-IndexedTraversal.html#t:IndexedTraversal">IndexedTraversal</a></code> with access to the index,
discarding the results (with the arguments flipped).
</p><pre><code><a href="Control-Lens-WithIndex.html#v:iforM_">iforM_</a></code> = <code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Prelude.html#v:flip">flip</a></code> <code><a href="Control-Lens-WithIndex.html#v:imapM_">imapM_</a></code></pre><p>When you don't need access to the index then <code><a href="Control-Lens-Fold.html#v:forMOf_">forMOf_</a></code> is more flexible in what it accepts.
</p><pre><code><a href="Control-Lens-Fold.html#v:forMOf_">forMOf_</a></code> l a = <code><a href="Control-Lens-IndexedTraversal.html#v:iforMOf">iforMOf</a></code> l a . <code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Prelude.html#v:const">const</a></code></pre></div></div><div class="top"><p class="src"><a name="v:iconcatMap" class="def">iconcatMap</a> :: <a href="Control-Lens-WithIndex.html#t:FoldableWithIndex">FoldableWithIndex</a> i f => (i -> a -> [b]) -> f a -> [b]<a href="src/Control-Lens-WithIndex.html#iconcatMap" class="link">Source</a></p><div class="doc"><p>Concatenate the results of a function of the elements of an indexed container with access to the index.
</p><p>When you don't need access to the index then <code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Foldable.html#v:concatMap">concatMap</a></code> is more flexible in what it accepts.
</p><pre>
<code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Foldable.html#v:concatMap">concatMap</a></code> = <code><a href="Control-Lens-WithIndex.html#v:iconcatMap">iconcatMap</a></code> . <code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Prelude.html#v:const">const</a></code>
<code><a href="Control-Lens-WithIndex.html#v:iconcatMap">iconcatMap</a></code> = <code><a href="Control-Lens-WithIndex.html#v:ifoldMap">ifoldMap</a></code>
</pre></div></div><div class="top"><p class="src"><a name="v:ifind" class="def">ifind</a> :: <a href="Control-Lens-WithIndex.html#t:FoldableWithIndex">FoldableWithIndex</a> i f => (i -> a -> <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Bool.html#t:Bool">Bool</a>) -> f a -> <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Maybe.html#t:Maybe">Maybe</a> (i, a)<a href="src/Control-Lens-WithIndex.html#ifind" class="link">Source</a></p><div class="doc"><p>Searches a container with a predicate that is also supplied the index, returning the left-most element of the structure
matching the predicate, or <code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Maybe.html#v:Nothing">Nothing</a></code> if there is no such element.
</p><p>When you don't need access to the index then <code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Foldable.html#v:find">find</a></code> is more flexible in what it accepts.
</p><pre><code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Foldable.html#v:find">find</a></code> = <code><a href="Control-Lens-WithIndex.html#v:ifind">ifind</a></code> . <code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Prelude.html#v:const">const</a></code></pre></div></div><div class="top"><p class="src"><a name="v:ifoldrM" class="def">ifoldrM</a> :: (<a href="Control-Lens-WithIndex.html#t:FoldableWithIndex">FoldableWithIndex</a> i f, <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Control-Monad.html#t:Monad">Monad</a> m) => (i -> a -> b -> m b) -> b -> f a -> m b<a href="src/Control-Lens-WithIndex.html#ifoldrM" class="link">Source</a></p><div class="doc"><p>Monadic fold right over the elements of a structure with an index.
</p><p>When you don't need access to the index then <code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Foldable.html#v:foldrM">foldrM</a></code> is more flexible in what it accepts.
</p><pre><code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Foldable.html#v:foldrM">foldrM</a></code> = <code><a href="Control-Lens-WithIndex.html#v:ifoldrM">ifoldrM</a></code> . <code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Prelude.html#v:const">const</a></code></pre></div></div><div class="top"><p class="src"><a name="v:ifoldlM" class="def">ifoldlM</a> :: (<a href="Control-Lens-WithIndex.html#t:FoldableWithIndex">FoldableWithIndex</a> i f, <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Control-Monad.html#t:Monad">Monad</a> m) => (i -> b -> a -> m b) -> b -> f a -> m b<a href="src/Control-Lens-WithIndex.html#ifoldlM" class="link">Source</a></p><div class="doc"><p>Monadic fold over the elements of a structure with an index, associating to the left.
</p><p>When you don't need access to the index then <code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Foldable.html#v:foldlM">foldlM</a></code> is more flexible in what it accepts.
</p><pre><code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Foldable.html#v:foldlM">foldlM</a></code> = <code><a href="Control-Lens-WithIndex.html#v:ifoldlM">ifoldlM</a></code> . <code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Prelude.html#v:const">const</a></code></pre></div></div><div class="top"><p class="src"><a name="v:itoList" class="def">itoList</a> :: <a href="Control-Lens-WithIndex.html#t:FoldableWithIndex">FoldableWithIndex</a> i f => f a -> [(i, a)]<a href="src/Control-Lens-WithIndex.html#itoList" class="link">Source</a></p><div class="doc"><p>Extract the key-value pairs from a structure.
</p><p>When you don't need access to the indices in the result, then <code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/containers-0.4.2.1/Data-IntMap.html#v:toList">toList</a></code> is more flexible in what it accepts.
</p><pre><code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/containers-0.4.2.1/Data-IntMap.html#v:toList">toList</a></code> = <code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/containers-0.4.2.1/Data-IntMap.html#v:map">map</a></code> <code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Tuple.html#v:fst">fst</a></code> . <code><a href="Control-Lens-WithIndex.html#v:itoList">itoList</a></code></pre></div></div><h1 id="g:4">Converting to Folds
</h1><div class="top"><p class="src"><a name="v:withIndices" class="def">withIndices</a> :: <a href="Control-Lens-WithIndex.html#t:FoldableWithIndex">FoldableWithIndex</a> i f => <a href="Control-Lens-Fold.html#t:Fold">Fold</a> (f a) (i, a)<a href="src/Control-Lens-WithIndex.html#withIndices" class="link">Source</a></p><div class="doc"><p>Fold a container with indices returning both the indices and the values.
</p></div></div><div class="top"><p class="src"><a name="v:indices" class="def">indices</a> :: <a href="Control-Lens-WithIndex.html#t:FoldableWithIndex">FoldableWithIndex</a> i f => <a href="Control-Lens-Fold.html#t:Fold">Fold</a> (f a) i<a href="src/Control-Lens-WithIndex.html#indices" class="link">Source</a></p><div class="doc"><p>Fold a container with indices returning only the indices.
</p></div></div><h1 id="g:5">Indexed Traversables
</h1><div class="top"><p class="src"><span class="keyword">class</span> (<a href="Control-Lens-WithIndex.html#t:FunctorWithIndex">FunctorWithIndex</a> i t, <a href="Control-Lens-WithIndex.html#t:FoldableWithIndex">FoldableWithIndex</a> i t, <a href="Control-Lens-Traversal.html#t:Traversable">Traversable</a> t) => <a name="t:TraversableWithIndex" class="def">TraversableWithIndex</a> i t | t -> i <span class="keyword">where</span><a href="src/Control-Lens-WithIndex.html#TraversableWithIndex" class="link">Source</a></p><div class="doc"><p>A <code><a href="Control-Lens-Traversal.html#t:Traversable">Traversable</a></code> with an additional index.
</p><p>An instance must satisfy a (modified) form of the <code><a href="Control-Lens-Traversal.html#t:Traversable">Traversable</a></code> laws:
</p><pre>
<code><a href="Control-Lens-WithIndex.html#v:itraverse">itraverse</a></code> (<code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Prelude.html#v:const">const</a></code> <code><a href="/Library/Haskell/ghc-7.4.1/lib/transformers-0.3.0.0/doc/html/Data-Functor-Identity.html#t:Identity">Identity</a></code>) = <code><a href="/Library/Haskell/ghc-7.4.1/lib/transformers-0.3.0.0/doc/html/Data-Functor-Identity.html#t:Identity">Identity</a></code>
<code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Control-Monad.html#v:fmap">fmap</a></code> (<code><a href="Control-Lens-WithIndex.html#v:itraverse">itraverse</a></code> f) <code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Prelude.html#v:.">.</a></code> <code><a href="Control-Lens-WithIndex.html#v:itraverse">itraverse</a></code> g = <code>getCompose</code> <code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Prelude.html#v:.">.</a></code> <code><a href="Control-Lens-WithIndex.html#v:itraverse">itraverse</a></code> (i -> <code>Compose</code> <code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Prelude.html#v:.">.</a></code> <code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Control-Monad.html#v:fmap">fmap</a></code> (f i) <code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Prelude.html#v:.">.</a></code> g i)
</pre></div><div class="subs methods"><p class="caption">Methods</p><p class="src"><a name="v:itraverse" class="def">itraverse</a> :: <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Control-Applicative.html#t:Applicative">Applicative</a> f => (i -> a -> f b) -> t a -> f (t b)<a href="src/Control-Lens-WithIndex.html#itraverse" class="link">Source</a></p><div class="doc"><p>Traverse an indexed container.
</p></div></div><div class="subs instances"><p id="control.i:TraversableWithIndex" class="caption collapser" onclick="toggleSection('i:TraversableWithIndex')">Instances</p><div id="section.i:TraversableWithIndex" class="show"><table><tr><td class="src"><a href="Control-Lens-WithIndex.html#t:TraversableWithIndex">TraversableWithIndex</a> <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Int.html#t:Int">Int</a> []</td><td class="doc empty"> </td></tr><tr><td class="src"><a href="Control-Lens-WithIndex.html#t:TraversableWithIndex">TraversableWithIndex</a> <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Int.html#t:Int">Int</a> <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/containers-0.4.2.1/Data-Sequence.html#t:Seq">Seq</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a href="Control-Lens-WithIndex.html#t:TraversableWithIndex">TraversableWithIndex</a> <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Int.html#t:Int">Int</a> <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/containers-0.4.2.1/Data-IntMap.html#t:IntMap">IntMap</a></td><td class="doc empty"> </td></tr><tr><td class="src">(<a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Eq.html#t:Eq">Eq</a> k, Hashable k) => <a href="Control-Lens-WithIndex.html#t:TraversableWithIndex">TraversableWithIndex</a> k (HashMap k)</td><td class="doc empty"> </td></tr><tr><td class="src"><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Ord.html#t:Ord">Ord</a> k => <a href="Control-Lens-WithIndex.html#t:TraversableWithIndex">TraversableWithIndex</a> k (<a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/containers-0.4.2.1/Data-Map.html#t:Map">Map</a> k)</td><td class="doc empty"> </td></tr></table></div></div></div><div class="top"><p class="src"><a name="v:itraversed" class="def">itraversed</a> :: <a href="Control-Lens-WithIndex.html#t:TraversableWithIndex">TraversableWithIndex</a> i f => <a href="Control-Lens-IndexedTraversal.html#t:IndexedTraversal">IndexedTraversal</a> i (f a) (f b) a b<a href="src/Control-Lens-WithIndex.html#itraversed" class="link">Source</a></p><div class="doc"><p>The <code><a href="Control-Lens-IndexedTraversal.html#t:IndexedTraversal">IndexedTraversal</a></code> of a <code><a href="Control-Lens-WithIndex.html#t:TraversableWithIndex">TraversableWithIndex</a></code> container.
</p></div></div><h1 id="g:6">Indexed Traversable Combinators
</h1><div class="top"><p class="src"><a name="v:ifor" class="def">ifor</a> :: (<a href="Control-Lens-WithIndex.html#t:TraversableWithIndex">TraversableWithIndex</a> i t, <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Control-Applicative.html#t:Applicative">Applicative</a> f) => t a -> (i -> a -> f b) -> f (t b)<a href="src/Control-Lens-WithIndex.html#ifor" class="link">Source</a></p><div class="doc"><p>Traverse with an index (and the arguments flipped)
</p><pre>
<code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Traversable.html#v:for">for</a></code> a = <code><a href="Control-Lens-WithIndex.html#v:ifor">ifor</a></code> a . <code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Prelude.html#v:const">const</a></code>
<code><a href="Control-Lens-WithIndex.html#v:ifor">ifor</a></code> = <code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Prelude.html#v:flip">flip</a></code> <code><a href="Control-Lens-WithIndex.html#v:itraverse">itraverse</a></code>
</pre></div></div><div class="top"><p class="src"><a name="v:imapM" class="def">imapM</a> :: (<a href="Control-Lens-WithIndex.html#t:TraversableWithIndex">TraversableWithIndex</a> i t, <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Control-Monad.html#t:Monad">Monad</a> m) => (i -> a -> m b) -> t a -> m (t b)<a href="src/Control-Lens-WithIndex.html#imapM" class="link">Source</a></p><div class="doc"><p>Map each element of a structure to a monadic action,
evaluate these actions from left to right, and collect the results, with access
the index.
</p><p>When you don't need access to the index <code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Traversable.html#v:mapM">mapM</a></code> is more liberal in what it can accept.
</p><pre><code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Traversable.html#v:mapM">mapM</a></code> = <code><a href="Control-Lens-WithIndex.html#v:imapM">imapM</a></code> . <code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Prelude.html#v:const">const</a></code></pre></div></div><div class="top"><p class="src"><a name="v:iforM" class="def">iforM</a> :: (<a href="Control-Lens-WithIndex.html#t:TraversableWithIndex">TraversableWithIndex</a> i t, <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Control-Monad.html#t:Monad">Monad</a> m) => t a -> (i -> a -> m b) -> m (t b)<a href="src/Control-Lens-WithIndex.html#iforM" class="link">Source</a></p><div class="doc"><p>Map each element of a structure to a monadic action,
evaluate these actions from left to right, and collect the results, with access
its position (and the arguments flipped).
</p><pre>
<code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Traversable.html#v:forM">forM</a></code> a = <code><a href="Control-Lens-WithIndex.html#v:iforM">iforM</a></code> a . <code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Prelude.html#v:const">const</a></code>
<code><a href="Control-Lens-WithIndex.html#v:iforM">iforM</a></code> = <code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Prelude.html#v:flip">flip</a></code> <code><a href="Control-Lens-WithIndex.html#v:imapM">imapM</a></code>
</pre></div></div><div class="top"><p class="src"><a name="v:imapAccumR" class="def">imapAccumR</a> :: <a href="Control-Lens-WithIndex.html#t:TraversableWithIndex">TraversableWithIndex</a> i t => (i -> s -> a -> (s, b)) -> s -> t a -> (s, t b)<a href="src/Control-Lens-WithIndex.html#imapAccumR" class="link">Source</a></p><div class="doc"><p>Generalizes <code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Traversable.html#v:mapAccumR">mapAccumR</a></code> to add access to the index.
</p><p><code><a href="Control-Lens-IndexedTraversal.html#v:imapAccumROf">imapAccumROf</a></code> accumulates state from right to left.
</p><pre><code><a href="Control-Lens-Traversal.html#v:mapAccumR">mapAccumR</a></code> = <code><a href="Control-Lens-WithIndex.html#v:imapAccumR">imapAccumR</a></code> . <code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Prelude.html#v:const">const</a></code></pre></div></div><div class="top"><p class="src"><a name="v:imapAccumL" class="def">imapAccumL</a> :: <a href="Control-Lens-WithIndex.html#t:TraversableWithIndex">TraversableWithIndex</a> i t => (i -> s -> a -> (s, b)) -> s -> t a -> (s, t b)<a href="src/Control-Lens-WithIndex.html#imapAccumL" class="link">Source</a></p><div class="doc"><p>Generalizes <code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Traversable.html#v:mapAccumL">mapAccumL</a></code> to add access to the index.
</p><p><code><a href="Control-Lens-IndexedTraversal.html#v:imapAccumLOf">imapAccumLOf</a></code> accumulates state from left to right.
</p><pre><code><a href="Control-Lens-Traversal.html#v:mapAccumLOf">mapAccumLOf</a></code> = <code><a href="Control-Lens-WithIndex.html#v:imapAccumL">imapAccumL</a></code> . <code><a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Prelude.html#v:const">const</a></code></pre></div></div><div class="top"><p class="src"><a name="v:iwhere" class="def">iwhere</a> :: <a href="Control-Lens-WithIndex.html#t:TraversableWithIndex">TraversableWithIndex</a> i t => (i -> <a href="/Library/Frameworks/GHC.framework/Versions/7.4.1-x86_64/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Bool.html#t:Bool">Bool</a>) -> <a href="Control-Lens-IndexedTraversal.html#t:SimpleIndexedTraversal">SimpleIndexedTraversal</a> i (t a) a<a href="src/Control-Lens-WithIndex.html#iwhere" class="link">Source</a></p><div class="doc"><p>Access the element of an indexed container where the index matches a predicate.
</p><pre class="screen"><code class="prompt">>>> </code><strong class="userinput"><code>:m + Control.Lens
</code></strong><code class="prompt">>>> </code><strong class="userinput"><code>over (iwhere (>0)) Prelude.reverse $ ["He","was","stressed","o_O"]
</code></strong>["He","saw","desserts","O_o"]
</pre></div></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.10.0</p></div></body></html>