This class permits overloading of function application for things that also admit a notion of a key or index.
Modulelens-5.3.5Haskell2010
Control.Lens.Indexed
(The classes in here need to be defined together for DefaultSignatures to work.)
- 1 type
- 5 classes
- 37 values
- Packagelens-5.3.5
- Exports43
- LanguageHaskell2010
- LicenceBSD-2-Clause
- SourceIndexed.hs
Indexing
11 declarationsclass (Choice p, Corepresentable p, Comonad (Corep p), Traversable (Corep p), Strong p, Representable p, Monad (Rep p), MonadFix (Rep p), Distributive (Rep p), Costrong p, ArrowLoop p, ArrowApply p, ArrowChoice p, Closed p) => Conjoined (p :: Type -> Type -> Type) whereThis is a Profunctor that is both Corepresentable by f and Representable by g such
that f is left adjoint to g. From this you can derive a lot of structure due
to the preservation of limits and colimits.
Methods
distrib :: Functor f => p a b -> p (f a) (f b)Conjoined is strong enough to let us distribute every Conjoined Profunctor over every Haskell Functor. This is effectively a generalization of fmap.
conjoined :: (p ~ (->) => q (a -> b) r) -> q (p a b) r -> q (p a b) rThis permits us to make a decision at an outermost point about whether or not we use an index.
Ideally any use of this function should be done in such a way so that you compute the same answer, but this cannot be enforced at the type level.
Instances3Conjoined
Conjoined ReifiedGetterDefined in lens-5.3.5 · Control.Lens.ReifiedConjoined (Indexed i)Defined in lens-5.3.5 · Control.Lens.Internal.IndexedConjoined (->)Defined in lens-5.3.5 · Control.Lens.Internal.Indexed
A function with access to a index. This constructor may be useful when you need to store
an Indexable in a container to avoid ImpredicativeTypes.
index :: Indexed i a b -> i -> a -> bConstructors
IndexedrunIndexed :: i -> a -> b
Instances27Category, Indexable, Arrow, ArrowApply, ArrowChoice, ArrowLoop, …
Category (Indexed i)Defined in lens-5.3.5 · Control.Lens.Internal.Indexedi ~ j => Indexable i (Indexed j)Defined in lens-5.3.5 · Control.Lens.Internal.IndexedArrow (Indexed i)Defined in lens-5.3.5 · Control.Lens.Internal.IndexedArrowApply (Indexed i)Defined in lens-5.3.5 · Control.Lens.Internal.IndexedArrowChoice (Indexed i)Defined in lens-5.3.5 · Control.Lens.Internal.IndexedArrowLoop (Indexed i)Defined in lens-5.3.5 · Control.Lens.Internal.IndexedChoice (Indexed i)Defined in lens-5.3.5 · Control.Lens.Internal.IndexedClosed (Indexed i)Defined in lens-5.3.5 · Control.Lens.Internal.IndexedCostrong (Indexed i)Defined in lens-5.3.5 · Control.Lens.Internal.IndexedStrong (Indexed i)Defined in lens-5.3.5 · Control.Lens.Internal.IndexedProfunctor (Indexed i)Defined in lens-5.3.5 · Control.Lens.Internal.IndexedCorepresentable (Indexed i)Defined in lens-5.3.5 · Control.Lens.Internal.IndexedRepresentable (Indexed i)Defined in lens-5.3.5 · Control.Lens.Internal.IndexedConjoined (Indexed i)Defined in lens-5.3.5 · Control.Lens.Internal.IndexedBizarre (Indexed Int) MaficDefined in lens-5.3.5 · Control.Lens.Internal.MagmaCosieve (Indexed i) (Tuple2 i)Defined in lens-5.3.5 · Control.Lens.Internal.IndexedBizarre (Indexed i) (Molten i)Defined in lens-5.3.5 · Control.Lens.Internal.MagmaSellable (Indexed i) (Molten i)Defined in lens-5.3.5 · Control.Lens.Internal.MagmaSieve (Indexed i) ((->) i)Defined in lens-5.3.5 · Control.Lens.Internal.IndexedMonad (Indexed i a)Defined in lens-5.3.5 · Control.Lens.Internal.IndexedFunctor (Indexed i a)Defined in lens-5.3.5 · Control.Lens.Internal.IndexedMonadFix (Indexed i a)Defined in lens-5.3.5 · Control.Lens.Internal.IndexedApplicative (Indexed i a)Defined in lens-5.3.5 · Control.Lens.Internal.IndexedApply (Indexed i a)Defined in lens-5.3.5 · Control.Lens.Internal.IndexedBind (Indexed i a)Defined in lens-5.3.5 · Control.Lens.Internal.Indexedtype Corep (Indexed i) = Tuple2 iDefined in lens-5.3.5 · Control.Lens.Internal.Indexedtype Rep (Indexed i) = (->) iDefined in lens-5.3.5 · Control.Lens.Internal.Indexed
Compose an Indexed function with a non-indexed function.
Mnemonically, the < points to the indexing we want to preserve.
let nestedMap = (fmap Map.fromList . Map.fromList) [(1, [(10, "one,ten"), (20, "one,twenty")]), (2, [(30, "two,thirty"), (40,"two,forty")])]nestedMap^..(itraversed<.itraversed).withIndex[(1,"one,ten"),(1,"one,twenty"),(2,"two,thirty"),(2,"two,forty")]
Composition of Indexed functions.
Mnemonically, the < and > points to the fact that we want to preserve the indices.
let nestedMap = (fmap Map.fromList . Map.fromList) [(1, [(10, "one,ten"), (20, "one,twenty")]), (2, [(30, "two,thirty"), (40,"two,forty")])]nestedMap^..(itraversed<.>itraversed).withIndex[((1,10),"one,ten"),((1,20),"one,twenty"),((2,30),"two,thirty"),((2,40),"two,forty")]
Compose a non-indexed function with an Indexed function.
Mnemonically, the > points to the indexing we want to preserve.
This is the same as (.).
f . g (and f .> g) gives you the index of g unless g is index-preserving, like a
Prism, Iso or Equality, in which case it'll pass through the index of f.
let nestedMap = (fmap Map.fromList . Map.fromList) [(1, [(10, "one,ten"), (20, "one,twenty")]), (2, [(30, "two,thirty"), (40,"two,forty")])]nestedMap^..(itraversed.>itraversed).withIndex[(10,"one,ten"),(20,"one,twenty"),(30,"two,thirty"),(40,"two,forty")]
Use a value itself as its own index. This is essentially an indexed version of id.
Note: When used to modify the value, this can break the index requirements assumed by indices and similar, so this is only properly an IndexedGetter, but it can be used as more.
selfIndex :: IndexedGetter a a b
Remap the index.
Composition of Indexed functions with a user supplied function for combining indices.
Transform a Control.Lens.Traversal.Traversal into an Control.Lens.Traversal.IndexedTraversal or
a Control.Lens.Fold.Fold into an Control.Lens.Fold.IndexedFold, etc.
indexing :: Traversal s t a b -> IndexedTraversal Int s t a b
indexing :: Prism s t a b -> IndexedTraversal Int s t a b
indexing :: Lens s t a b -> IndexedLens Int s t a b
indexing :: Iso s t a b -> IndexedLens Int s t a b
indexing :: Fold s a -> IndexedFold Int s a
indexing :: Getter s a -> IndexedGetter Int s a
indexing :: Indexable Int p => LensLike (Indexing f) s t a b -> Over p f s t a bTransform a Control.Lens.Traversal.Traversal into an Control.Lens.Traversal.IndexedTraversal or
a Control.Lens.Fold.Fold into an Control.Lens.Fold.IndexedFold, etc.
This combinator is like indexing except that it handles large traversals and folds gracefully.
indexing64 :: Traversal s t a b -> IndexedTraversal Int64 s t a b
indexing64 :: Prism s t a b -> IndexedTraversal Int64 s t a b
indexing64 :: Lens s t a b -> IndexedLens Int64 s t a b
indexing64 :: Iso s t a b -> IndexedLens Int64 s t a b
indexing64 :: Fold s a -> IndexedFold Int64 s a
indexing64 :: Getter s a -> IndexedGetter Int64 s a
indexing64 :: Indexable Int64 p => LensLike (Indexing64 f) s t a b -> Over p f s t a bIndexed Functors
1 declarationA Functor with an additional index.
Instances must satisfy a modified form of the Functor laws:
imap f . imap g ≡ imap (\i -> f i . g i)
imap (\_ a -> a) ≡ id
Methods
imap :: (i -> a -> b) -> f a -> f bMap with access to the index.
Instances40FunctorWithIndex, …
FunctorWithIndex Int IntMapDefined in indexed-traversable-0.1.4 · WithIndexFunctorWithIndex Int SeqDefined in indexed-traversable-0.1.4 · WithIndexThe position in the Seq is available as the index.
FunctorWithIndex Int NonEmptyDefined in indexed-traversable-0.1.4 · WithIndexFunctorWithIndex Int ZipListDefined in indexed-traversable-0.1.4 · WithIndexSame instance as for
[].FunctorWithIndex Int DequeDefined in lens-5.3.5 · Control.Lens.Internal.DequeFunctorWithIndex Int VectorDefined in indexed-traversable-instances-0.1.2 · Data.Functor.WithIndex.Instances · orphanFunctorWithIndex Int []Defined in indexed-traversable-0.1.4 · WithIndexThe position in the list is available as the index.
FunctorWithIndex () IdentityDefined in indexed-traversable-0.1.4 · WithIndexFunctorWithIndex () Par1Defined in indexed-traversable-0.1.4 · WithIndexFunctorWithIndex () MaybeDefined in indexed-traversable-0.1.4 · WithIndexFunctorWithIndex () SoloDefined in indexed-traversable-instances-0.1.2 · Data.Functor.WithIndex.Instances · orphanIx i => FunctorWithIndex i (Array i)Defined in indexed-traversable-0.1.4 · WithIndexFunctorWithIndex Void ProxyDefined in indexed-traversable-0.1.4 · WithIndexFunctorWithIndex Void U1Defined in indexed-traversable-0.1.4 · WithIndexFunctorWithIndex Void V1Defined in indexed-traversable-0.1.4 · WithIndexFunctorWithIndex i (Level i)Defined in lens-5.3.5 · Control.Lens.Internal.LevelFunctorWithIndex k (Map k)Defined in indexed-traversable-0.1.4 · WithIndexFunctorWithIndex k (Tuple2 k)Defined in indexed-traversable-0.1.4 · WithIndexFunctorWithIndex k (HashMap k)Defined in indexed-traversable-instances-0.1.2 · Data.Functor.WithIndex.Instances · orphanFunctorWithIndex Void (Const e)Defined in indexed-traversable-0.1.4 · WithIndexFunctorWithIndex Void (Constant e)Defined in indexed-traversable-0.1.4 · WithIndexFunctorWithIndex () (Tagged a)Defined in indexed-traversable-instances-0.1.2 · Data.Functor.WithIndex.Instances · orphanFunctorWithIndex i f => FunctorWithIndex i (Rec1 f)Defined in indexed-traversable-0.1.4 · WithIndexFunctorWithIndex i f => FunctorWithIndex i (Backwards f)Defined in indexed-traversable-0.1.4 · WithIndexFunctorWithIndex i f => FunctorWithIndex i (Reverse f)Defined in indexed-traversable-0.1.4 · WithIndexFunctorWithIndex i m => FunctorWithIndex i (IdentityT m)Defined in indexed-traversable-0.1.4 · WithIndexFunctorWithIndex Void (K1 i c)Defined in indexed-traversable-0.1.4 · WithIndexFunctorWithIndex i (Magma i t b)Defined in lens-5.3.5 · Control.Lens.Internal.MagmaFunctorWithIndex r ((->) r)Defined in indexed-traversable-0.1.4 · WithIndexFunctorWithIndex [Int] TreeDefined in indexed-traversable-0.1.4 · WithIndexFunctorWithIndex i f => FunctorWithIndex [i] (Cofree f)Defined in free-5.2 · Control.Comonad.CofreeFunctorWithIndex i f => FunctorWithIndex [i] (Free f)Defined in free-5.2 · Control.Monad.FreeFunctorWithIndex i m => FunctorWithIndex (e, i) (ReaderT e m)Defined in indexed-traversable-0.1.4 · WithIndexFunctorWithIndex i w => FunctorWithIndex (s, i) (TracedT s w)Defined in comonad-5.0.9 · Control.Comonad.Trans.Traced(FunctorWithIndex i f, FunctorWithIndex j g) => FunctorWithIndex (Either i j) (Product f g)Defined in indexed-traversable-0.1.4 · WithIndex(FunctorWithIndex i f, FunctorWithIndex j g) => FunctorWithIndex (Either i j) (Sum f g)Defined in indexed-traversable-0.1.4 · WithIndex(FunctorWithIndex i f, FunctorWithIndex j g) => FunctorWithIndex (Either i j) (f :*: g)Defined in indexed-traversable-0.1.4 · WithIndex(FunctorWithIndex i f, FunctorWithIndex j g) => FunctorWithIndex (Either i j) (f :+: g)Defined in indexed-traversable-0.1.4 · WithIndex(FunctorWithIndex i f, FunctorWithIndex j g) => FunctorWithIndex (i, j) (Compose f g)Defined in indexed-traversable-0.1.4 · WithIndex(FunctorWithIndex i f, FunctorWithIndex j g) => FunctorWithIndex (i, j) (f :.: g)Defined in indexed-traversable-0.1.4 · WithIndex
Indexed Functor Combinators
The IndexedSetter for a FunctorWithIndex.
If you don't need access to the index, then mapped is more flexible in what it accepts.
Indexed Foldables
1 declarationA container that supports folding with an additional index.
Methods
Instances37FoldableWithIndex, …
FoldableWithIndex Int IntMapDefined in indexed-traversable-0.1.4 · WithIndexFoldableWithIndex Int SeqDefined in indexed-traversable-0.1.4 · WithIndexFoldableWithIndex Int NonEmptyDefined in indexed-traversable-0.1.4 · WithIndexFoldableWithIndex Int ZipListDefined in indexed-traversable-0.1.4 · WithIndexFoldableWithIndex Int DequeDefined in lens-5.3.5 · Control.Lens.Internal.DequeFoldableWithIndex Int VectorDefined in indexed-traversable-instances-0.1.2 · Data.Functor.WithIndex.Instances · orphanFoldableWithIndex Int []Defined in indexed-traversable-0.1.4 · WithIndexFoldableWithIndex () IdentityDefined in indexed-traversable-0.1.4 · WithIndexFoldableWithIndex () Par1Defined in indexed-traversable-0.1.4 · WithIndexFoldableWithIndex () MaybeDefined in indexed-traversable-0.1.4 · WithIndexFoldableWithIndex () SoloDefined in indexed-traversable-instances-0.1.2 · Data.Functor.WithIndex.Instances · orphanIx i => FoldableWithIndex i (Array i)Defined in indexed-traversable-0.1.4 · WithIndexFoldableWithIndex Void ProxyDefined in indexed-traversable-0.1.4 · WithIndexFoldableWithIndex Void U1Defined in indexed-traversable-0.1.4 · WithIndexFoldableWithIndex Void V1Defined in indexed-traversable-0.1.4 · WithIndexFoldableWithIndex i (Level i)Defined in lens-5.3.5 · Control.Lens.Internal.LevelFoldableWithIndex k (Map k)Defined in indexed-traversable-0.1.4 · WithIndexFoldableWithIndex k (Tuple2 k)Defined in indexed-traversable-0.1.4 · WithIndexFoldableWithIndex k (HashMap k)Defined in indexed-traversable-instances-0.1.2 · Data.Functor.WithIndex.Instances · orphanFoldableWithIndex Void (Const e)Defined in indexed-traversable-0.1.4 · WithIndexFoldableWithIndex Void (Constant e)Defined in indexed-traversable-0.1.4 · WithIndexFoldableWithIndex () (Tagged a)Defined in indexed-traversable-instances-0.1.2 · Data.Functor.WithIndex.Instances · orphanFoldableWithIndex i f => FoldableWithIndex i (Rec1 f)Defined in indexed-traversable-0.1.4 · WithIndexFoldableWithIndex i f => FoldableWithIndex i (Backwards f)Defined in indexed-traversable-0.1.4 · WithIndexFoldableWithIndex i f => FoldableWithIndex i (Reverse f)Defined in indexed-traversable-0.1.4 · WithIndexFoldableWithIndex i m => FoldableWithIndex i (IdentityT m)Defined in indexed-traversable-0.1.4 · WithIndexFoldableWithIndex Void (K1 i c)Defined in indexed-traversable-0.1.4 · WithIndexFoldableWithIndex i (Magma i t b)Defined in lens-5.3.5 · Control.Lens.Internal.MagmaFoldableWithIndex [Int] TreeDefined in indexed-traversable-0.1.4 · WithIndexFoldableWithIndex i f => FoldableWithIndex [i] (Cofree f)Defined in free-5.2 · Control.Comonad.CofreeFoldableWithIndex i f => FoldableWithIndex [i] (Free f)Defined in free-5.2 · Control.Monad.Free(FoldableWithIndex i f, FoldableWithIndex j g) => FoldableWithIndex (Either i j) (Product f g)Defined in indexed-traversable-0.1.4 · WithIndex(FoldableWithIndex i f, FoldableWithIndex j g) => FoldableWithIndex (Either i j) (Sum f g)Defined in indexed-traversable-0.1.4 · WithIndex(FoldableWithIndex i f, FoldableWithIndex j g) => FoldableWithIndex (Either i j) (f :*: g)Defined in indexed-traversable-0.1.4 · WithIndex(FoldableWithIndex i f, FoldableWithIndex j g) => FoldableWithIndex (Either i j) (f :+: g)Defined in indexed-traversable-0.1.4 · WithIndex(FoldableWithIndex i f, FoldableWithIndex j g) => FoldableWithIndex (i, j) (Compose f g)Defined in indexed-traversable-0.1.4 · WithIndex(FoldableWithIndex i f, FoldableWithIndex j g) => FoldableWithIndex (i, j) (f :.: g)Defined in indexed-traversable-0.1.4 · WithIndex
Indexed Foldable Combinators
The IndexedFold of a FoldableWithIndex container.
ifolded . asIndex is a fold over the keys of a FoldableWithIndex.
Data.Map.fromList [(2, "hello"), (1, "world")]^..ifolded.asIndex[1,2]
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
Run monadic actions for each target of an IndexedFold or Control.Lens.IndexedTraversal.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
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
Converting to Folds
2 declarationsFold a container with indices returning both the indices and the values.
The result is only valid to compose in a Traversal, if you don't edit the
index as edits to the index have no effect.
[10, 20, 30] ^.. ifolded . withIndex[(0,10),(1,20),(2,30)]
[10, 20, 30] ^.. ifolded . withIndex . alongside negated (re _Show)[(0,"10"),(-1,"20"),(-2,"30")]
When composed with an IndexedFold or IndexedTraversal this yields an
(Indexed) Fold of the indices.
Restricting by Index
2 declarationsThis allows you to filter an IndexedFold, IndexedGetter, IndexedTraversal or IndexedLens based on a predicate on the indices.
["hello","the","world","!!!"]^..traversed.indices even["hello","world"]
over (traversed.indices (>0)) Prelude.reverse $ ["He","was","stressed","o_O"]["He","saw","desserts","O_o"]
This allows you to filter an IndexedFold, IndexedGetter, IndexedTraversal or IndexedLens based on an index.
["hello","the","world","!!!"]^?traversed.index 2Just "world"
Indexed Traversables
1 declarationclass (FunctorWithIndex i t, FoldableWithIndex i t, Traversable t) => TraversableWithIndex i (t :: Type -> Type) | t -> i whereA Traversable with an additional index.
An instance must satisfy a (modified) form of the Traversable laws:
itraverse (const Identity) ≡ Identity
fmap (itraverse f) . itraverse g ≡ getCompose . itraverse (\i -> Compose . fmap (f i) . g i)
Methods
itraverse :: Applicative f => (i -> a -> f b) -> t a -> f (t b)Traverse an indexed container.
itraverse ≡itraverseOfitraversed
Instances37TraversableWithIndex, …
TraversableWithIndex Int IntMapDefined in indexed-traversable-0.1.4 · WithIndexTraversableWithIndex Int SeqDefined in indexed-traversable-0.1.4 · WithIndexTraversableWithIndex Int NonEmptyDefined in indexed-traversable-0.1.4 · WithIndexTraversableWithIndex Int ZipListDefined in indexed-traversable-0.1.4 · WithIndexTraversableWithIndex Int DequeDefined in lens-5.3.5 · Control.Lens.Internal.DequeTraversableWithIndex Int VectorDefined in indexed-traversable-instances-0.1.2 · Data.Functor.WithIndex.Instances · orphanTraversableWithIndex Int []Defined in indexed-traversable-0.1.4 · WithIndexTraversableWithIndex () IdentityDefined in indexed-traversable-0.1.4 · WithIndexTraversableWithIndex () Par1Defined in indexed-traversable-0.1.4 · WithIndexTraversableWithIndex () MaybeDefined in indexed-traversable-0.1.4 · WithIndexTraversableWithIndex () SoloDefined in indexed-traversable-instances-0.1.2 · Data.Functor.WithIndex.Instances · orphanIx i => TraversableWithIndex i (Array i)Defined in indexed-traversable-0.1.4 · WithIndexTraversableWithIndex Void ProxyDefined in indexed-traversable-0.1.4 · WithIndexTraversableWithIndex Void U1Defined in indexed-traversable-0.1.4 · WithIndexTraversableWithIndex Void V1Defined in indexed-traversable-0.1.4 · WithIndexTraversableWithIndex i (Level i)Defined in lens-5.3.5 · Control.Lens.Internal.LevelTraversableWithIndex k (Map k)Defined in indexed-traversable-0.1.4 · WithIndexTraversableWithIndex k (Tuple2 k)Defined in indexed-traversable-0.1.4 · WithIndexTraversableWithIndex k (HashMap k)Defined in indexed-traversable-instances-0.1.2 · Data.Functor.WithIndex.Instances · orphanTraversableWithIndex Void (Const e)Defined in indexed-traversable-0.1.4 · WithIndexTraversableWithIndex Void (Constant e)Defined in indexed-traversable-0.1.4 · WithIndexTraversableWithIndex () (Tagged a)Defined in indexed-traversable-instances-0.1.2 · Data.Functor.WithIndex.Instances · orphanTraversableWithIndex i f => TraversableWithIndex i (Rec1 f)Defined in indexed-traversable-0.1.4 · WithIndexTraversableWithIndex i f => TraversableWithIndex i (Backwards f)Defined in indexed-traversable-0.1.4 · WithIndexTraversableWithIndex i f => TraversableWithIndex i (Reverse f)Defined in indexed-traversable-0.1.4 · WithIndexTraversableWithIndex i m => TraversableWithIndex i (IdentityT m)Defined in indexed-traversable-0.1.4 · WithIndexTraversableWithIndex Void (K1 i c)Defined in indexed-traversable-0.1.4 · WithIndexTraversableWithIndex i (Magma i t b)Defined in lens-5.3.5 · Control.Lens.Internal.MagmaTraversableWithIndex [Int] TreeDefined in indexed-traversable-0.1.4 · WithIndexTraversableWithIndex i f => TraversableWithIndex [i] (Cofree f)Defined in free-5.2 · Control.Comonad.CofreeTraversableWithIndex i f => TraversableWithIndex [i] (Free f)Defined in free-5.2 · Control.Monad.Free(TraversableWithIndex i f, TraversableWithIndex j g) => TraversableWithIndex (Either i j) (Product f g)Defined in indexed-traversable-0.1.4 · WithIndex(TraversableWithIndex i f, TraversableWithIndex j g) => TraversableWithIndex (Either i j) (Sum f g)Defined in indexed-traversable-0.1.4 · WithIndex(TraversableWithIndex i f, TraversableWithIndex j g) => TraversableWithIndex (Either i j) (f :*: g)Defined in indexed-traversable-0.1.4 · WithIndex(TraversableWithIndex i f, TraversableWithIndex j g) => TraversableWithIndex (Either i j) (f :+: g)Defined in indexed-traversable-0.1.4 · WithIndex(TraversableWithIndex i f, TraversableWithIndex j g) => TraversableWithIndex (i, j) (Compose f g)Defined in indexed-traversable-0.1.4 · WithIndex(TraversableWithIndex i f, TraversableWithIndex j g) => TraversableWithIndex (i, j) (f :.: g)Defined in indexed-traversable-0.1.4 · WithIndex
Indexed Traversable Combinators
6 declarationsThe IndexedTraversal of a TraversableWithIndex container.
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.
When you don't need access to the index mapM is more liberal in what it can accept.
mapM ≡ imapM . const
Generalizes Data.Traversable.mapAccumR to add access to the index.
imapAccumR accumulates state from right to left.
Data.Traversable.mapAccumR ≡ imapAccumR . const
Generalizes Data.Traversable.mapAccumL to add access to the index.
imapAccumL accumulates state from left to right.
Data.Traversable.mapAccumL ≡ imapAccumL . const