| Safe Haskell | None | 
|---|---|
| Language | Haskell2010 | 
Optics.Indexed
Description
This module defines general functionality for indexed optics.  See the
 "Indexed optics" section of the overview documentation in the Optics module
 of the main optics package for more details.
Unlike Optics.Indexed.Core, this includes the definitions from modules for
 specific indexed optic flavours such as Optics.IxTraversal, and includes
 additional instances for FunctorWithIndex and similar classes.
Synopsis
- class IxOptic k s t a b where
 - conjoined :: forall (is :: IxList) i k s t a b. HasSingleIndex is i => Optic k NoIx s t a b -> Optic k is s t a b -> Optic k is s t a b
 - (<%>) :: forall k l m s t a b (is :: IxList) i (js :: IxList) j u v. (JoinKinds k l m, IxOptic m s t a b, HasSingleIndex is i, HasSingleIndex js j) => Optic k is s t u v -> Optic l js u v a b -> Optic m (WithIx (i, j)) s t a b
 - (%>) :: forall k l m s t u v (is :: IxList) (js :: IxList) a b. (JoinKinds k l m, IxOptic k s t u v, NonEmptyIndices is) => Optic k is s t u v -> Optic l js u v a b -> Optic m js s t a b
 - (<%) :: forall k l m u v a b (js :: IxList) (is :: IxList) s t. (JoinKinds k l m, IxOptic l u v a b, NonEmptyIndices js) => Optic k is s t u v -> Optic l js u v a b -> Optic m is s t a b
 - reindexed :: forall (is :: IxList) i j k s t a b. HasSingleIndex is i => (i -> j) -> Optic k is s t a b -> Optic k (WithIx j) s t a b
 - icompose :: (i -> j -> ix) -> Optic k '[i, j] s t a b -> Optic k (WithIx ix) s t a b
 - icompose3 :: (i1 -> i2 -> i3 -> ix) -> Optic k '[i1, i2, i3] s t a b -> Optic k (WithIx ix) s t a b
 - icompose4 :: (i1 -> i2 -> i3 -> i4 -> ix) -> Optic k '[i1, i2, i3, i4] s t a b -> Optic k (WithIx ix) s t a b
 - icompose5 :: (i1 -> i2 -> i3 -> i4 -> i5 -> ix) -> Optic k '[i1, i2, i3, i4, i5] s t a b -> Optic k (WithIx ix) s t a b
 - icomposeN :: forall k i (is :: IxList) s t a b. (CurryCompose is, NonEmptyIndices is) => Curry is i -> Optic k is s t a b -> Optic k (WithIx i) s t a b
 - module Optics.IxAffineFold
 - module Optics.IxAffineTraversal
 - module Optics.IxFold
 - module Optics.IxGetter
 - module Optics.IxLens
 - module Optics.IxSetter
 - module Optics.IxTraversal
 - class Functor f => FunctorWithIndex i (f :: Type -> Type) | f -> i where
- imap :: (i -> a -> b) -> f a -> f b
 
 - class Foldable f => FoldableWithIndex i (f :: Type -> Type) | f -> i where
 - itraverse_ :: (FoldableWithIndex i t, Applicative f) => (i -> a -> f b) -> t a -> f ()
 - ifor_ :: (FoldableWithIndex i t, Applicative f) => t a -> (i -> a -> f b) -> f ()
 - itoList :: FoldableWithIndex i f => f a -> [(i, a)]
 - class (FunctorWithIndex i t, FoldableWithIndex i t, Traversable t) => TraversableWithIndex i (t :: Type -> Type) | t -> i where
- itraverse :: Applicative f => (i -> a -> f b) -> t a -> f (t b)
 
 - ifor :: (TraversableWithIndex i t, Applicative f) => t a -> (i -> a -> f b) -> f (t b)
 
Class for optic kinds that can be indexed
class IxOptic k s t a b where Source #
Class for optic kinds that can have indices.
Methods
noIx :: forall (is :: IxList). NonEmptyIndices is => Optic k is s t a b -> Optic k NoIx s t a b Source #
Convert an indexed optic to its unindexed equivalent.
Instances
| (s ~ t, a ~ b) => IxOptic A_Fold s t a b | |
| (s ~ t, a ~ b) => IxOptic A_Getter s t a b | |
| IxOptic A_Lens s t a b | |
| IxOptic A_Setter s t a b | |
| IxOptic A_Traversal s t a b | |
Defined in Optics.Indexed.Core Methods noIx :: forall (is :: IxList). NonEmptyIndices is => Optic A_Traversal is s t a b -> Optic A_Traversal NoIx s t a b Source #  | |
| (s ~ t, a ~ b) => IxOptic An_AffineFold s t a b | |
Defined in Optics.Indexed.Core Methods noIx :: forall (is :: IxList). NonEmptyIndices is => Optic An_AffineFold is s t a b -> Optic An_AffineFold NoIx s t a b Source #  | |
| IxOptic An_AffineTraversal s t a b | |
Defined in Optics.Indexed.Core Methods noIx :: forall (is :: IxList). NonEmptyIndices is => Optic An_AffineTraversal is s t a b -> Optic An_AffineTraversal NoIx s t a b Source #  | |
conjoined :: forall (is :: IxList) i k s t a b. HasSingleIndex is i => Optic k NoIx s t a b -> Optic k is s t a b -> Optic k is s t a b Source #
Composition of indexed optics
(<%>) :: forall k l m s t a b (is :: IxList) i (js :: IxList) j u v. (JoinKinds k l m, IxOptic m s t a b, HasSingleIndex is i, HasSingleIndex js j) => Optic k is s t u v -> Optic l js u v a b -> Optic m (WithIx (i, j)) s t a b infixl 9 Source #
Compose two indexed optics. Their indices are composed as a pair.
>>>itoListOf (ifolded <%> ifolded) ["foo", "bar"][((0,0),'f'),((0,1),'o'),((0,2),'o'),((1,0),'b'),((1,1),'a'),((1,2),'r')]
(%>) :: forall k l m s t u v (is :: IxList) (js :: IxList) a b. (JoinKinds k l m, IxOptic k s t u v, NonEmptyIndices is) => Optic k is s t u v -> Optic l js u v a b -> Optic m js s t a b infixl 9 Source #
Compose two indexed optics and drop indices of the left one. (If you want
 to compose a non-indexed and an indexed optic, you can just use (%).)
>>>itoListOf (ifolded %> ifolded) ["foo", "bar"][(0,'f'),(1,'o'),(2,'o'),(0,'b'),(1,'a'),(2,'r')]
(<%) :: forall k l m u v a b (js :: IxList) (is :: IxList) s t. (JoinKinds k l m, IxOptic l u v a b, NonEmptyIndices js) => Optic k is s t u v -> Optic l js u v a b -> Optic m is s t a b infixl 9 Source #
Compose two indexed optics and drop indices of the right one. (If you want
 to compose an indexed and a non-indexed optic, you can just use (%).)
>>>itoListOf (ifolded <% ifolded) ["foo", "bar"][(0,'f'),(0,'o'),(0,'o'),(1,'b'),(1,'a'),(1,'r')]
reindexed :: forall (is :: IxList) i j k s t a b. HasSingleIndex is i => (i -> j) -> Optic k is s t a b -> Optic k (WithIx j) s t a b Source #
Remap the index.
>>>itoListOf (reindexed succ ifolded) "foo"[(1,'f'),(2,'o'),(3,'o')]
>>>itoListOf (ifolded %& reindexed succ) "foo"[(1,'f'),(2,'o'),(3,'o')]
icompose :: (i -> j -> ix) -> Optic k '[i, j] s t a b -> Optic k (WithIx ix) s t a b Source #
Flatten indices obtained from two indexed optics.
>>>itoListOf (ifolded % ifolded %& icompose (,)) ["foo","bar"][((0,0),'f'),((0,1),'o'),((0,2),'o'),((1,0),'b'),((1,1),'a'),((1,2),'r')]
icompose3 :: (i1 -> i2 -> i3 -> ix) -> Optic k '[i1, i2, i3] s t a b -> Optic k (WithIx ix) s t a b Source #
Flatten indices obtained from three indexed optics.
>>>itoListOf (ifolded % ifolded % ifolded %& icompose3 (,,)) [["foo","bar"],["xyz"]][((0,0,0),'f'),((0,0,1),'o'),((0,0,2),'o'),((0,1,0),'b'),((0,1,1),'a'),((0,1,2),'r'),((1,0,0),'x'),((1,0,1),'y'),((1,0,2),'z')]
icompose4 :: (i1 -> i2 -> i3 -> i4 -> ix) -> Optic k '[i1, i2, i3, i4] s t a b -> Optic k (WithIx ix) s t a b Source #
Flatten indices obtained from four indexed optics.
icompose5 :: (i1 -> i2 -> i3 -> i4 -> i5 -> ix) -> Optic k '[i1, i2, i3, i4, i5] s t a b -> Optic k (WithIx ix) s t a b Source #
Flatten indices obtained from five indexed optics.
icomposeN :: forall k i (is :: IxList) s t a b. (CurryCompose is, NonEmptyIndices is) => Curry is i -> Optic k is s t a b -> Optic k (WithIx i) s t a b Source #
Flatten indices obtained from arbitrary number of indexed optics.
Indexed optic flavours
module Optics.IxAffineFold
module Optics.IxAffineTraversal
module Optics.IxFold
module Optics.IxGetter
module Optics.IxLens
module Optics.IxSetter
module Optics.IxTraversal
Functors with index
class Functor f => FunctorWithIndex i (f :: Type -> Type) | f -> i where Source #
A Functor with an additional index.
Instances must satisfy a modified form of the Functor laws:
imapf.imapg ≡imap(\i -> f i.g i)imap(\_ a -> a) ≡id
Minimal complete definition
Nothing
Methods
imap :: (i -> a -> b) -> f a -> f b Source #
Map with access to the index.
default imap :: TraversableWithIndex i f => (i -> a -> b) -> f a -> f b Source #
Instances
Foldable with index
class Foldable f => FoldableWithIndex i (f :: Type -> Type) | f -> i where Source #
A container that supports folding with an additional index.
Minimal complete definition
Nothing
Methods
ifoldMap :: Monoid m => (i -> a -> m) -> f a -> m Source #
Fold a container by mapping value to an arbitrary Monoid with access to the index i.
When you don't need access to the index then foldMap is more flexible in what it accepts.
foldMap≡ifoldMap.const
default ifoldMap :: (TraversableWithIndex i f, Monoid m) => (i -> a -> m) -> f a -> m Source #
ifoldMap' :: Monoid m => (i -> a -> m) -> f a -> m Source #
A variant of ifoldMap that is strict in the accumulator.
When you don't need access to the index then foldMap' is more flexible in what it accepts.
foldMap'≡ifoldMap'.const
ifoldr :: (i -> a -> b -> b) -> b -> f a -> b Source #
Right-associative fold of an indexed container with access to the index i.
When you don't need access to the index then foldr is more flexible in what it accepts.
foldr≡ifoldr.const
ifoldl :: (i -> b -> a -> b) -> b -> f a -> b Source #
Left-associative fold of an indexed container with access to the index i.
When you don't need access to the index then foldl is more flexible in what it accepts.
foldl≡ifoldl.const
Instances
| FoldableWithIndex () Identity | |
Defined in WithIndex Methods ifoldMap :: Monoid m => (() -> a -> m) -> Identity a -> m Source # ifoldMap' :: Monoid m => (() -> a -> m) -> Identity a -> m Source # ifoldr :: (() -> a -> b -> b) -> b -> Identity a -> b Source # ifoldl :: (() -> b -> a -> b) -> b -> Identity a -> b Source # ifoldr' :: (() -> a -> b -> b) -> b -> Identity a -> b Source # ifoldl' :: (() -> b -> a -> b) -> b -> Identity a -> b Source #  | |
| FoldableWithIndex () Par1 | |
Defined in WithIndex Methods ifoldMap :: Monoid m => (() -> a -> m) -> Par1 a -> m Source # ifoldMap' :: Monoid m => (() -> a -> m) -> Par1 a -> m Source # ifoldr :: (() -> a -> b -> b) -> b -> Par1 a -> b Source # ifoldl :: (() -> b -> a -> b) -> b -> Par1 a -> b Source #  | |
| FoldableWithIndex () Maybe | |
Defined in WithIndex Methods ifoldMap :: Monoid m => (() -> a -> m) -> Maybe a -> m Source # ifoldMap' :: Monoid m => (() -> a -> m) -> Maybe a -> m Source # ifoldr :: (() -> a -> b -> b) -> b -> Maybe a -> b Source # ifoldl :: (() -> b -> a -> b) -> b -> Maybe a -> b Source # ifoldr' :: (() -> a -> b -> b) -> b -> Maybe a -> b Source # ifoldl' :: (() -> b -> a -> b) -> b -> Maybe a -> b Source #  | |
| FoldableWithIndex Int ZipList | |
Defined in WithIndex Methods ifoldMap :: Monoid m => (Int -> a -> m) -> ZipList a -> m Source # ifoldMap' :: Monoid m => (Int -> a -> m) -> ZipList a -> m Source # ifoldr :: (Int -> a -> b -> b) -> b -> ZipList a -> b Source # ifoldl :: (Int -> b -> a -> b) -> b -> ZipList a -> b Source # ifoldr' :: (Int -> a -> b -> b) -> b -> ZipList a -> b Source # ifoldl' :: (Int -> b -> a -> b) -> b -> ZipList a -> b Source #  | |
| FoldableWithIndex Int NonEmpty | |
Defined in WithIndex Methods ifoldMap :: Monoid m => (Int -> a -> m) -> NonEmpty a -> m Source # ifoldMap' :: Monoid m => (Int -> a -> m) -> NonEmpty a -> m Source # ifoldr :: (Int -> a -> b -> b) -> b -> NonEmpty a -> b Source # ifoldl :: (Int -> b -> a -> b) -> b -> NonEmpty a -> b Source # ifoldr' :: (Int -> a -> b -> b) -> b -> NonEmpty a -> b Source # ifoldl' :: (Int -> b -> a -> b) -> b -> NonEmpty a -> b Source #  | |
| FoldableWithIndex Int IntMap | |
Defined in WithIndex Methods ifoldMap :: Monoid m => (Int -> a -> m) -> IntMap a -> m Source # ifoldMap' :: Monoid m => (Int -> a -> m) -> IntMap a -> m Source # ifoldr :: (Int -> a -> b -> b) -> b -> IntMap a -> b Source # ifoldl :: (Int -> b -> a -> b) -> b -> IntMap a -> b Source # ifoldr' :: (Int -> a -> b -> b) -> b -> IntMap a -> b Source # ifoldl' :: (Int -> b -> a -> b) -> b -> IntMap a -> b Source #  | |
| FoldableWithIndex Int Seq | |
Defined in WithIndex Methods ifoldMap :: Monoid m => (Int -> a -> m) -> Seq a -> m Source # ifoldMap' :: Monoid m => (Int -> a -> m) -> Seq a -> m Source # ifoldr :: (Int -> a -> b -> b) -> b -> Seq a -> b Source # ifoldl :: (Int -> b -> a -> b) -> b -> Seq a -> b Source #  | |
| FoldableWithIndex Int [] | |
Defined in WithIndex  | |
| FoldableWithIndex Void (Proxy :: Type -> Type) | |
Defined in WithIndex Methods ifoldMap :: Monoid m => (Void -> a -> m) -> Proxy a -> m Source # ifoldMap' :: Monoid m => (Void -> a -> m) -> Proxy a -> m Source # ifoldr :: (Void -> a -> b -> b) -> b -> Proxy a -> b Source # ifoldl :: (Void -> b -> a -> b) -> b -> Proxy a -> b Source # ifoldr' :: (Void -> a -> b -> b) -> b -> Proxy a -> b Source # ifoldl' :: (Void -> b -> a -> b) -> b -> Proxy a -> b Source #  | |
| FoldableWithIndex Void (U1 :: Type -> Type) | |
Defined in WithIndex Methods ifoldMap :: Monoid m => (Void -> a -> m) -> U1 a -> m Source # ifoldMap' :: Monoid m => (Void -> a -> m) -> U1 a -> m Source # ifoldr :: (Void -> a -> b -> b) -> b -> U1 a -> b Source # ifoldl :: (Void -> b -> a -> b) -> b -> U1 a -> b Source #  | |
| FoldableWithIndex Void (V1 :: Type -> Type) | |
Defined in WithIndex Methods ifoldMap :: Monoid m => (Void -> a -> m) -> V1 a -> m Source # ifoldMap' :: Monoid m => (Void -> a -> m) -> V1 a -> m Source # ifoldr :: (Void -> a -> b -> b) -> b -> V1 a -> b Source # ifoldl :: (Void -> b -> a -> b) -> b -> V1 a -> b Source #  | |
| Ix i => FoldableWithIndex i (Array i) | |
Defined in WithIndex Methods ifoldMap :: Monoid m => (i -> a -> m) -> Array i a -> m Source # ifoldMap' :: Monoid m => (i -> a -> m) -> Array i a -> m Source # ifoldr :: (i -> a -> b -> b) -> b -> Array i a -> b Source # ifoldl :: (i -> b -> a -> b) -> b -> Array i a -> b Source # ifoldr' :: (i -> a -> b -> b) -> b -> Array i a -> b Source # ifoldl' :: (i -> b -> a -> b) -> b -> Array i a -> b Source #  | |
| FoldableWithIndex k (Map k) | |
Defined in WithIndex Methods ifoldMap :: Monoid m => (k -> a -> m) -> Map k a -> m Source # ifoldMap' :: Monoid m => (k -> a -> m) -> Map k a -> m Source # ifoldr :: (k -> a -> b -> b) -> b -> Map k a -> b Source # ifoldl :: (k -> b -> a -> b) -> b -> Map k a -> b Source #  | |
| FoldableWithIndex k ((,) k) | |
Defined in WithIndex Methods ifoldMap :: Monoid m => (k -> a -> m) -> (k, a) -> m Source # ifoldMap' :: Monoid m => (k -> a -> m) -> (k, a) -> m Source # ifoldr :: (k -> a -> b -> b) -> b -> (k, a) -> b Source # ifoldl :: (k -> b -> a -> b) -> b -> (k, a) -> b Source #  | |
| FoldableWithIndex Void (Const e :: Type -> Type) | |
Defined in WithIndex Methods ifoldMap :: Monoid m => (Void -> a -> m) -> Const e a -> m Source # ifoldMap' :: Monoid m => (Void -> a -> m) -> Const e a -> m Source # ifoldr :: (Void -> a -> b -> b) -> b -> Const e a -> b Source # ifoldl :: (Void -> b -> a -> b) -> b -> Const e a -> b Source # ifoldr' :: (Void -> a -> b -> b) -> b -> Const e a -> b Source # ifoldl' :: (Void -> b -> a -> b) -> b -> Const e a -> b Source #  | |
| FoldableWithIndex Void (Constant e :: Type -> Type) | |
Defined in WithIndex Methods ifoldMap :: Monoid m => (Void -> a -> m) -> Constant e a -> m Source # ifoldMap' :: Monoid m => (Void -> a -> m) -> Constant e a -> m Source # ifoldr :: (Void -> a -> b -> b) -> b -> Constant e a -> b Source # ifoldl :: (Void -> b -> a -> b) -> b -> Constant e a -> b Source # ifoldr' :: (Void -> a -> b -> b) -> b -> Constant e a -> b Source # ifoldl' :: (Void -> b -> a -> b) -> b -> Constant e a -> b Source #  | |
| FoldableWithIndex i f => FoldableWithIndex i (Rec1 f) | |
Defined in WithIndex Methods ifoldMap :: Monoid m => (i -> a -> m) -> Rec1 f a -> m Source # ifoldMap' :: Monoid m => (i -> a -> m) -> Rec1 f a -> m Source # ifoldr :: (i -> a -> b -> b) -> b -> Rec1 f a -> b Source # ifoldl :: (i -> b -> a -> b) -> b -> Rec1 f a -> b Source # ifoldr' :: (i -> a -> b -> b) -> b -> Rec1 f a -> b Source # ifoldl' :: (i -> b -> a -> b) -> b -> Rec1 f a -> b Source #  | |
| FoldableWithIndex i f => FoldableWithIndex i (Backwards f) | |
Defined in WithIndex Methods ifoldMap :: Monoid m => (i -> a -> m) -> Backwards f a -> m Source # ifoldMap' :: Monoid m => (i -> a -> m) -> Backwards f a -> m Source # ifoldr :: (i -> a -> b -> b) -> b -> Backwards f a -> b Source # ifoldl :: (i -> b -> a -> b) -> b -> Backwards f a -> b Source # ifoldr' :: (i -> a -> b -> b) -> b -> Backwards f a -> b Source # ifoldl' :: (i -> b -> a -> b) -> b -> Backwards f a -> b Source #  | |
| FoldableWithIndex i m => FoldableWithIndex i (IdentityT m) | |
Defined in WithIndex Methods ifoldMap :: Monoid m0 => (i -> a -> m0) -> IdentityT m a -> m0 Source # ifoldMap' :: Monoid m0 => (i -> a -> m0) -> IdentityT m a -> m0 Source # ifoldr :: (i -> a -> b -> b) -> b -> IdentityT m a -> b Source # ifoldl :: (i -> b -> a -> b) -> b -> IdentityT m a -> b Source # ifoldr' :: (i -> a -> b -> b) -> b -> IdentityT m a -> b Source # ifoldl' :: (i -> b -> a -> b) -> b -> IdentityT m a -> b Source #  | |
| FoldableWithIndex i f => FoldableWithIndex i (Reverse f) | |
Defined in WithIndex Methods ifoldMap :: Monoid m => (i -> a -> m) -> Reverse f a -> m Source # ifoldMap' :: Monoid m => (i -> a -> m) -> Reverse f a -> m Source # ifoldr :: (i -> a -> b -> b) -> b -> Reverse f a -> b Source # ifoldl :: (i -> b -> a -> b) -> b -> Reverse f a -> b Source # ifoldr' :: (i -> a -> b -> b) -> b -> Reverse f a -> b Source # ifoldl' :: (i -> b -> a -> b) -> b -> Reverse f a -> b Source #  | |
| FoldableWithIndex Void (K1 i c :: Type -> Type) | |
Defined in WithIndex Methods ifoldMap :: Monoid m => (Void -> a -> m) -> K1 i c a -> m Source # ifoldMap' :: Monoid m => (Void -> a -> m) -> K1 i c a -> m Source # ifoldr :: (Void -> a -> b -> b) -> b -> K1 i c a -> b Source # ifoldl :: (Void -> b -> a -> b) -> b -> K1 i c a -> b Source # ifoldr' :: (Void -> a -> b -> b) -> b -> K1 i c a -> b Source # ifoldl' :: (Void -> b -> a -> b) -> b -> K1 i c a -> b Source #  | |
| FoldableWithIndex [Int] Tree | |
Defined in WithIndex Methods ifoldMap :: Monoid m => ([Int] -> a -> m) -> Tree a -> m Source # ifoldMap' :: Monoid m => ([Int] -> a -> m) -> Tree a -> m Source # ifoldr :: ([Int] -> a -> b -> b) -> b -> Tree a -> b Source # ifoldl :: ([Int] -> b -> a -> b) -> b -> Tree a -> b Source # ifoldr' :: ([Int] -> a -> b -> b) -> b -> Tree a -> b Source # ifoldl' :: ([Int] -> b -> a -> b) -> b -> Tree a -> b Source #  | |
| (FoldableWithIndex i f, FoldableWithIndex j g) => FoldableWithIndex (Either i j) (Product f g) | |
Defined in WithIndex Methods ifoldMap :: Monoid m => (Either i j -> a -> m) -> Product f g a -> m Source # ifoldMap' :: Monoid m => (Either i j -> a -> m) -> Product f g a -> m Source # ifoldr :: (Either i j -> a -> b -> b) -> b -> Product f g a -> b Source # ifoldl :: (Either i j -> b -> a -> b) -> b -> Product f g a -> b Source # ifoldr' :: (Either i j -> a -> b -> b) -> b -> Product f g a -> b Source # ifoldl' :: (Either i j -> b -> a -> b) -> b -> Product f g a -> b Source #  | |
| (FoldableWithIndex i f, FoldableWithIndex j g) => FoldableWithIndex (Either i j) (Sum f g) | |
Defined in WithIndex Methods ifoldMap :: Monoid m => (Either i j -> a -> m) -> Sum f g a -> m Source # ifoldMap' :: Monoid m => (Either i j -> a -> m) -> Sum f g a -> m Source # ifoldr :: (Either i j -> a -> b -> b) -> b -> Sum f g a -> b Source # ifoldl :: (Either i j -> b -> a -> b) -> b -> Sum f g a -> b Source # ifoldr' :: (Either i j -> a -> b -> b) -> b -> Sum f g a -> b Source # ifoldl' :: (Either i j -> b -> a -> b) -> b -> Sum f g a -> b Source #  | |
| (FoldableWithIndex i f, FoldableWithIndex j g) => FoldableWithIndex (Either i j) (f :*: g) | |
Defined in WithIndex Methods ifoldMap :: Monoid m => (Either i j -> a -> m) -> (f :*: g) a -> m Source # ifoldMap' :: Monoid m => (Either i j -> a -> m) -> (f :*: g) a -> m Source # ifoldr :: (Either i j -> a -> b -> b) -> b -> (f :*: g) a -> b Source # ifoldl :: (Either i j -> b -> a -> b) -> b -> (f :*: g) a -> b Source # ifoldr' :: (Either i j -> a -> b -> b) -> b -> (f :*: g) a -> b Source # ifoldl' :: (Either i j -> b -> a -> b) -> b -> (f :*: g) a -> b Source #  | |
| (FoldableWithIndex i f, FoldableWithIndex j g) => FoldableWithIndex (Either i j) (f :+: g) | |
Defined in WithIndex Methods ifoldMap :: Monoid m => (Either i j -> a -> m) -> (f :+: g) a -> m Source # ifoldMap' :: Monoid m => (Either i j -> a -> m) -> (f :+: g) a -> m Source # ifoldr :: (Either i j -> a -> b -> b) -> b -> (f :+: g) a -> b Source # ifoldl :: (Either i j -> b -> a -> b) -> b -> (f :+: g) a -> b Source # ifoldr' :: (Either i j -> a -> b -> b) -> b -> (f :+: g) a -> b Source # ifoldl' :: (Either i j -> b -> a -> b) -> b -> (f :+: g) a -> b Source #  | |
| (FoldableWithIndex i f, FoldableWithIndex j g) => FoldableWithIndex (i, j) (Compose f g) | |
Defined in WithIndex Methods ifoldMap :: Monoid m => ((i, j) -> a -> m) -> Compose f g a -> m Source # ifoldMap' :: Monoid m => ((i, j) -> a -> m) -> Compose f g a -> m Source # ifoldr :: ((i, j) -> a -> b -> b) -> b -> Compose f g a -> b Source # ifoldl :: ((i, j) -> b -> a -> b) -> b -> Compose f g a -> b Source # ifoldr' :: ((i, j) -> a -> b -> b) -> b -> Compose f g a -> b Source # ifoldl' :: ((i, j) -> b -> a -> b) -> b -> Compose f g a -> b Source #  | |
| (FoldableWithIndex i f, FoldableWithIndex j g) => FoldableWithIndex (i, j) (f :.: g) | |
Defined in WithIndex Methods ifoldMap :: Monoid m => ((i, j) -> a -> m) -> (f :.: g) a -> m Source # ifoldMap' :: Monoid m => ((i, j) -> a -> m) -> (f :.: g) a -> m Source # ifoldr :: ((i, j) -> a -> b -> b) -> b -> (f :.: g) a -> b Source # ifoldl :: ((i, j) -> b -> a -> b) -> b -> (f :.: g) a -> b Source # ifoldr' :: ((i, j) -> a -> b -> b) -> b -> (f :.: g) a -> b Source # ifoldl' :: ((i, j) -> b -> a -> b) -> b -> (f :.: g) a -> b Source #  | |
itraverse_ :: (FoldableWithIndex i t, Applicative f) => (i -> a -> f b) -> t a -> f () Source #
ifor_ :: (FoldableWithIndex i t, Applicative f) => t a -> (i -> a -> f b) -> f () Source #
Traverse elements with access to the index i, discarding the results (with the arguments flipped).
ifor_≡flipitraverse_
When you don't need access to the index then for_ is more flexible in what it accepts.
for_a ≡ifor_a.const
itoList :: FoldableWithIndex i f => f a -> [(i, a)] Source #
Traversable with index
class (FunctorWithIndex i t, FoldableWithIndex i t, Traversable t) => TraversableWithIndex i (t :: Type -> Type) | t -> i where Source #
A Traversable with an additional index.
An instance must satisfy a (modified) form of the Traversable laws:
itraverse(constIdentity) ≡Identityfmap(itraversef).itraverseg ≡getCompose.itraverse(\i ->Compose.fmap(f i).g i)
Minimal complete definition
Nothing
Methods
itraverse :: Applicative f => (i -> a -> f b) -> t a -> f (t b) Source #
Traverse an indexed container.
itraverse≡itraverseOfitraversed
Instances
ifor :: (TraversableWithIndex i t, Applicative f) => t a -> (i -> a -> f b) -> f (t b) Source #