lens-4.19: Lenses, Folds and Traversals

Copyright(C) 2012-16 Edward Kmett
LicenseBSD-style (see the file LICENSE)
MaintainerEdward Kmett <ekmett@gmail.com>
Stabilityprovisional
PortabilityRank2Types
Safe HaskellTrustworthy
LanguageHaskell2010

Control.Lens.Indexed

Contents

Description

(The classes in here need to be defined together for DefaultSignatures to work.)

Synopsis

Indexing

class Conjoined p => Indexable i p where Source #

This class permits overloading of function application for things that also admit a notion of a key or index.

Methods

indexed :: p a b -> i -> a -> b Source #

Build a function from an indexed function.

Instances
i ~ j => Indexable i (Indexed j) Source # 
Instance details

Defined in Control.Lens.Internal.Indexed

Methods

indexed :: Indexed j a b -> i -> a -> b Source #

Indexable i ((->) :: Type -> Type -> Type) Source # 
Instance details

Defined in Control.Lens.Internal.Indexed

Methods

indexed :: (a -> b) -> i -> a -> b Source #

class (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 where Source #

This 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.

Minimal complete definition

Nothing

Methods

distrib :: Functor f => p a b -> p (f a) (f b) Source #

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) r Source #

This 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.

Instances
Conjoined ReifiedGetter Source # 
Instance details

Defined in Control.Lens.Reified

Methods

distrib :: Functor f => ReifiedGetter a b -> ReifiedGetter (f a) (f b) Source #

conjoined :: ((ReifiedGetter ~ (->)) -> q (a -> b) r) -> q (ReifiedGetter a b) r -> q (ReifiedGetter a b) r Source #

Conjoined (Indexed i) Source # 
Instance details

Defined in Control.Lens.Internal.Indexed

Methods

distrib :: Functor f => Indexed i a b -> Indexed i (f a) (f b) Source #

conjoined :: ((Indexed i ~ (->)) -> q (a -> b) r) -> q (Indexed i a b) r -> q (Indexed i a b) r Source #

Conjoined ((->) :: Type -> Type -> Type) Source # 
Instance details

Defined in Control.Lens.Internal.Indexed

Methods

distrib :: Functor f => (a -> b) -> f a -> f b Source #

conjoined :: (((->) ~ (->)) -> q (a -> b) r) -> q (a -> b) r -> q (a -> b) r Source #

newtype Indexed i a b Source #

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 -> b

Constructors

Indexed 

Fields

Instances
i ~ j => Indexable i (Indexed j) Source # 
Instance details

Defined in Control.Lens.Internal.Indexed

Methods

indexed :: Indexed j a b -> i -> a -> b Source #

Arrow (Indexed i) Source # 
Instance details

Defined in Control.Lens.Internal.Indexed

Methods

arr :: (b -> c) -> Indexed i b c #

first :: Indexed i b c -> Indexed i (b, d) (c, d) #

second :: Indexed i b c -> Indexed i (d, b) (d, c) #

(***) :: Indexed i b c -> Indexed i b' c' -> Indexed i (b, b') (c, c') #

(&&&) :: Indexed i b c -> Indexed i b c' -> Indexed i b (c, c') #

ArrowChoice (Indexed i) Source # 
Instance details

Defined in Control.Lens.Internal.Indexed

Methods

left :: Indexed i b c -> Indexed i (Either b d) (Either c d) #

right :: Indexed i b c -> Indexed i (Either d b) (Either d c) #

(+++) :: Indexed i b c -> Indexed i b' c' -> Indexed i (Either b b') (Either c c') #

(|||) :: Indexed i b d -> Indexed i c d -> Indexed i (Either b c) d #

ArrowApply (Indexed i) Source # 
Instance details

Defined in Control.Lens.Internal.Indexed

Methods

app :: Indexed i (Indexed i b c, b) c #

ArrowLoop (Indexed i) Source # 
Instance details

Defined in Control.Lens.Internal.Indexed

Methods

loop :: Indexed i (b, d) (c, d) -> Indexed i b c #

Profunctor (Indexed i) Source # 
Instance details

Defined in Control.Lens.Internal.Indexed

Methods

dimap :: (a -> b) -> (c -> d) -> Indexed i b c -> Indexed i a d #

lmap :: (a -> b) -> Indexed i b c -> Indexed i a c #

rmap :: (b -> c) -> Indexed i a b -> Indexed i a c #

(#.) :: Coercible c b => q b c -> Indexed i a b -> Indexed i a c #

(.#) :: Coercible b a => Indexed i b c -> q a b -> Indexed i a c #

Representable (Indexed i) Source # 
Instance details

Defined in Control.Lens.Internal.Indexed

Associated Types

type Rep (Indexed i) :: Type -> Type #

Methods

tabulate :: (d -> Rep (Indexed i) c) -> Indexed i d c #

Corepresentable (Indexed i) Source # 
Instance details

Defined in Control.Lens.Internal.Indexed

Associated Types

type Corep (Indexed i) :: Type -> Type #

Methods

cotabulate :: (Corep (Indexed i) d -> c) -> Indexed i d c #

Choice (Indexed i) Source # 
Instance details

Defined in Control.Lens.Internal.Indexed

Methods

left' :: Indexed i a b -> Indexed i (Either a c) (Either b c) #

right' :: Indexed i a b -> Indexed i (Either c a) (Either c b) #

Closed (Indexed i) Source # 
Instance details

Defined in Control.Lens.Internal.Indexed

Methods

closed :: Indexed i a b -> Indexed i (x -> a) (x -> b) #

Strong (Indexed i) Source # 
Instance details

Defined in Control.Lens.Internal.Indexed

Methods

first' :: Indexed i a b -> Indexed i (a, c) (b, c) #

second' :: Indexed i a b -> Indexed i (c, a) (c, b) #

Costrong (Indexed i) Source # 
Instance details

Defined in Control.Lens.Internal.Indexed

Methods

unfirst :: Indexed i (a, d) (b, d) -> Indexed i a b #

unsecond :: Indexed i (d, a) (d, b) -> Indexed i a b #

Conjoined (Indexed i) Source # 
Instance details

Defined in Control.Lens.Internal.Indexed

Methods

distrib :: Functor f => Indexed i a b -> Indexed i (f a) (f b) Source #

conjoined :: ((Indexed i ~ (->)) -> q (a -> b) r) -> q (Indexed i a b) r -> q (Indexed i a b) r Source #

Bizarre (Indexed Int) Mafic Source # 
Instance details

Defined in Control.Lens.Internal.Magma

Methods

bazaar :: Applicative f => Indexed Int a (f b) -> Mafic a b t -> f t Source #

Category (Indexed i :: Type -> Type -> Type) Source # 
Instance details

Defined in Control.Lens.Internal.Indexed

Methods

id :: Indexed i a a #

(.) :: Indexed i b c -> Indexed i a b -> Indexed i a c #

Cosieve (Indexed i) ((,) i) Source # 
Instance details

Defined in Control.Lens.Internal.Indexed

Methods

cosieve :: Indexed i a b -> (i, a) -> b #

Sellable (Indexed i) (Molten i) Source # 
Instance details

Defined in Control.Lens.Internal.Magma

Methods

sell :: Indexed i a (Molten i a b b) Source #

Bizarre (Indexed i) (Molten i) Source # 
Instance details

Defined in Control.Lens.Internal.Magma

Methods

bazaar :: Applicative f => Indexed i a (f b) -> Molten i a b t -> f t Source #

Sieve (Indexed i) ((->) i :: Type -> Type) Source # 
Instance details

Defined in Control.Lens.Internal.Indexed

Methods

sieve :: Indexed i a b -> a -> i -> b #

Monad (Indexed i a) Source # 
Instance details

Defined in Control.Lens.Internal.Indexed

Methods

(>>=) :: Indexed i a a0 -> (a0 -> Indexed i a b) -> Indexed i a b #

(>>) :: Indexed i a a0 -> Indexed i a b -> Indexed i a b #

return :: a0 -> Indexed i a a0 #

fail :: String -> Indexed i a a0 #

Functor (Indexed i a) Source # 
Instance details

Defined in Control.Lens.Internal.Indexed

Methods

fmap :: (a0 -> b) -> Indexed i a a0 -> Indexed i a b #

(<$) :: a0 -> Indexed i a b -> Indexed i a a0 #

MonadFix (Indexed i a) Source # 
Instance details

Defined in Control.Lens.Internal.Indexed

Methods

mfix :: (a0 -> Indexed i a a0) -> Indexed i a a0 #

Applicative (Indexed i a) Source # 
Instance details

Defined in Control.Lens.Internal.Indexed

Methods

pure :: a0 -> Indexed i a a0 #

(<*>) :: Indexed i a (a0 -> b) -> Indexed i a a0 -> Indexed i a b #

liftA2 :: (a0 -> b -> c) -> Indexed i a a0 -> Indexed i a b -> Indexed i a c #

(*>) :: Indexed i a a0 -> Indexed i a b -> Indexed i a b #

(<*) :: Indexed i a a0 -> Indexed i a b -> Indexed i a a0 #

Apply (Indexed i a) Source # 
Instance details

Defined in Control.Lens.Internal.Indexed

Methods

(<.>) :: Indexed i a (a0 -> b) -> Indexed i a a0 -> Indexed i a b #

(.>) :: Indexed i a a0 -> Indexed i a b -> Indexed i a b #

(<.) :: Indexed i a a0 -> Indexed i a b -> Indexed i a a0 #

liftF2 :: (a0 -> b -> c) -> Indexed i a a0 -> Indexed i a b -> Indexed i a c #

Bind (Indexed i a) Source # 
Instance details

Defined in Control.Lens.Internal.Indexed

Methods

(>>-) :: Indexed i a a0 -> (a0 -> Indexed i a b) -> Indexed i a b #

join :: Indexed i a (Indexed i a a0) -> Indexed i a a0 #

type Rep (Indexed i) Source # 
Instance details

Defined in Control.Lens.Internal.Indexed

type Rep (Indexed i) = ((->) i :: Type -> Type)
type Corep (Indexed i) Source # 
Instance details

Defined in Control.Lens.Internal.Indexed

type Corep (Indexed i) = (,) i

(<.) :: Indexable i p => (Indexed i s t -> r) -> ((a -> b) -> s -> t) -> p a b -> r infixr 9 Source #

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")]

(<.>) :: Indexable (i, j) p => (Indexed i s t -> r) -> (Indexed j a b -> s -> t) -> p a b -> r infixr 9 Source #

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")]

(.>) :: (st -> r) -> (kab -> st) -> kab -> r infixr 9 Source #

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")]

selfIndex :: Indexable a p => p a fb -> a -> fb Source #

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

reindexed :: Indexable j p => (i -> j) -> (Indexed i a b -> r) -> p a b -> r Source #

Remap the index.

icompose :: Indexable p c => (i -> j -> p) -> (Indexed i s t -> r) -> (Indexed j a b -> s -> t) -> c a b -> r Source #

Composition of Indexed functions with a user supplied function for combining indices.

indexing :: Indexable Int p => ((a -> Indexing f b) -> s -> Indexing f t) -> p a (f b) -> s -> f t Source #

Transform a Traversal into an IndexedTraversal or a Fold into an 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 b

indexing64 :: Indexable Int64 p => ((a -> Indexing64 f b) -> s -> Indexing64 f t) -> p a (f b) -> s -> f t Source #

Transform a Traversal into an IndexedTraversal or a Fold into an 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 b

Indexed Functors

class Functor f => FunctorWithIndex i f | f -> i where Source #

A 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

Minimal complete definition

Nothing

Methods

imap :: (i -> a -> b) -> f a -> f b Source #

Map with access to the index.

imap :: TraversableWithIndex i f => (i -> a -> b) -> f a -> f b Source #

Map with access to the index.

imapped :: IndexedSetter i (f a) (f b) a b Source #

The IndexedSetter for a FunctorWithIndex.

If you don't need access to the index, then mapped is more flexible in what it accepts.

Instances
FunctorWithIndex Int [] Source #

The position in the list is available as the index.

Instance details

Defined in Control.Lens.Indexed

Methods

imap :: (Int -> a -> b) -> [a] -> [b] Source #

imapped :: IndexedSetter Int [a] [b] a b Source #

FunctorWithIndex Int ZipList Source #

Same instance as for [].

Instance details

Defined in Control.Lens.Indexed

Methods

imap :: (Int -> a -> b) -> ZipList a -> ZipList b Source #

imapped :: IndexedSetter Int (ZipList a) (ZipList b) a b Source #

FunctorWithIndex Int NonEmpty Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

imap :: (Int -> a -> b) -> NonEmpty a -> NonEmpty b Source #

imapped :: IndexedSetter Int (NonEmpty a) (NonEmpty b) a b Source #

FunctorWithIndex Int IntMap Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

imap :: (Int -> a -> b) -> IntMap a -> IntMap b Source #

imapped :: IndexedSetter Int (IntMap a) (IntMap b) a b Source #

FunctorWithIndex Int Seq Source #

The position in the Seq is available as the index.

Instance details

Defined in Control.Lens.Indexed

Methods

imap :: (Int -> a -> b) -> Seq a -> Seq b Source #

imapped :: IndexedSetter Int (Seq a) (Seq b) a b Source #

FunctorWithIndex Int Vector Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

imap :: (Int -> a -> b) -> Vector a -> Vector b Source #

imapped :: IndexedSetter Int (Vector a) (Vector b) a b Source #

FunctorWithIndex Int Deque Source # 
Instance details

Defined in Control.Lens.Internal.Deque

Methods

imap :: (Int -> a -> b) -> Deque a -> Deque b Source #

imapped :: IndexedSetter Int (Deque a) (Deque b) a b Source #

FunctorWithIndex () Maybe Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

imap :: (() -> a -> b) -> Maybe a -> Maybe b Source #

imapped :: IndexedSetter () (Maybe a) (Maybe b) a b Source #

FunctorWithIndex () Par1 Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

imap :: (() -> a -> b) -> Par1 a -> Par1 b Source #

imapped :: IndexedSetter () (Par1 a) (Par1 b) a b Source #

FunctorWithIndex () Identity Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

imap :: (() -> a -> b) -> Identity a -> Identity b Source #

imapped :: IndexedSetter () (Identity a) (Identity b) a b Source #

Ix i => FunctorWithIndex i (Array i) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

imap :: (i -> a -> b) -> Array i a -> Array i b Source #

imapped :: IndexedSetter i (Array i a) (Array i b) a b Source #

FunctorWithIndex i (Level i) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

imap :: (i -> a -> b) -> Level i a -> Level i b Source #

imapped :: IndexedSetter i (Level i a) (Level i b) a b Source #

FunctorWithIndex k (HashMap k) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

imap :: (k -> a -> b) -> HashMap k a -> HashMap k b Source #

imapped :: IndexedSetter k (HashMap k a) (HashMap k b) a b Source #

FunctorWithIndex k (Map k) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

imap :: (k -> a -> b) -> Map k a -> Map k b Source #

imapped :: IndexedSetter k (Map k a) (Map k b) a b Source #

FunctorWithIndex k ((,) k) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

imap :: (k -> a -> b) -> (k, a) -> (k, b) Source #

imapped :: IndexedSetter k (k, a) (k, b) a b Source #

FunctorWithIndex Void (V1 :: Type -> Type) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

imap :: (Void -> a -> b) -> V1 a -> V1 b Source #

imapped :: IndexedSetter Void (V1 a) (V1 b) a b Source #

FunctorWithIndex Void (U1 :: Type -> Type) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

imap :: (Void -> a -> b) -> U1 a -> U1 b Source #

imapped :: IndexedSetter Void (U1 a) (U1 b) a b Source #

FunctorWithIndex Void (Proxy :: Type -> Type) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

imap :: (Void -> a -> b) -> Proxy a -> Proxy b Source #

imapped :: IndexedSetter Void (Proxy a) (Proxy b) a b Source #

FunctorWithIndex () (Tagged a) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

imap :: (() -> a0 -> b) -> Tagged a a0 -> Tagged a b Source #

imapped :: IndexedSetter () (Tagged a a0) (Tagged a b) a0 b Source #

FunctorWithIndex i f => FunctorWithIndex i (Rec1 f) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

imap :: (i -> a -> b) -> Rec1 f a -> Rec1 f b Source #

imapped :: IndexedSetter i (Rec1 f a) (Rec1 f b) a b Source #

FunctorWithIndex i m => FunctorWithIndex i (IdentityT m) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

imap :: (i -> a -> b) -> IdentityT m a -> IdentityT m b Source #

imapped :: IndexedSetter i (IdentityT m a) (IdentityT m b) a b Source #

FunctorWithIndex i f => FunctorWithIndex i (Reverse f) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

imap :: (i -> a -> b) -> Reverse f a -> Reverse f b Source #

imapped :: IndexedSetter i (Reverse f a) (Reverse f b) a b Source #

FunctorWithIndex i f => FunctorWithIndex i (Backwards f) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

imap :: (i -> a -> b) -> Backwards f a -> Backwards f b Source #

imapped :: IndexedSetter i (Backwards f a) (Backwards f b) a b Source #

FunctorWithIndex Void (Const e :: Type -> Type) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

imap :: (Void -> a -> b) -> Const e a -> Const e b Source #

imapped :: IndexedSetter Void (Const e a) (Const e b) a b Source #

FunctorWithIndex Void (Constant e :: Type -> Type) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

imap :: (Void -> a -> b) -> Constant e a -> Constant e b Source #

imapped :: IndexedSetter Void (Constant e a) (Constant e b) a b Source #

FunctorWithIndex i (Magma i t b) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

imap :: (i -> a -> b0) -> Magma i t b a -> Magma i t b b0 Source #

imapped :: IndexedSetter i (Magma i t b a) (Magma i t b b0) a b0 Source #

FunctorWithIndex r ((->) r :: Type -> Type) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

imap :: (r -> a -> b) -> (r -> a) -> r -> b Source #

imapped :: IndexedSetter r (r -> a) (r -> b) a b Source #

FunctorWithIndex Void (K1 i c :: Type -> Type) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

imap :: (Void -> a -> b) -> K1 i c a -> K1 i c b Source #

imapped :: IndexedSetter Void (K1 i c a) (K1 i c b) a b Source #

FunctorWithIndex [Int] Tree Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

imap :: ([Int] -> a -> b) -> Tree a -> Tree b Source #

imapped :: IndexedSetter [Int] (Tree a) (Tree b) a b Source #

FunctorWithIndex i f => FunctorWithIndex [i] (Cofree f) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

imap :: ([i] -> a -> b) -> Cofree f a -> Cofree f b Source #

imapped :: IndexedSetter [i] (Cofree f a) (Cofree f b) a b Source #

FunctorWithIndex i f => FunctorWithIndex [i] (Free f) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

imap :: ([i] -> a -> b) -> Free f a -> Free f b Source #

imapped :: IndexedSetter [i] (Free f a) (Free f b) a b Source #

FunctorWithIndex i w => FunctorWithIndex (s, i) (TracedT s w) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

imap :: ((s, i) -> a -> b) -> TracedT s w a -> TracedT s w b Source #

imapped :: IndexedSetter (s, i) (TracedT s w a) (TracedT s w b) a b Source #

(FunctorWithIndex i f, FunctorWithIndex j g) => FunctorWithIndex (Either i j) (f :+: g) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

imap :: (Either i j -> a -> b) -> (f :+: g) a -> (f :+: g) b Source #

imapped :: IndexedSetter (Either i j) ((f :+: g) a) ((f :+: g) b) a b Source #

(FunctorWithIndex i f, FunctorWithIndex j g) => FunctorWithIndex (Either i j) (f :*: g) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

imap :: (Either i j -> a -> b) -> (f :*: g) a -> (f :*: g) b Source #

imapped :: IndexedSetter (Either i j) ((f :*: g) a) ((f :*: g) b) a b Source #

(FunctorWithIndex i f, FunctorWithIndex j g) => FunctorWithIndex (Either i j) (Product f g) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

imap :: (Either i j -> a -> b) -> Product f g a -> Product f g b Source #

imapped :: IndexedSetter (Either i j) (Product f g a) (Product f g b) a b Source #

(FunctorWithIndex i f, FunctorWithIndex j g) => FunctorWithIndex (Either i j) (Sum f g) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

imap :: (Either i j -> a -> b) -> Sum f g a -> Sum f g b Source #

imapped :: IndexedSetter (Either i j) (Sum f g a) (Sum f g b) a b Source #

FunctorWithIndex i m => FunctorWithIndex (e, i) (ReaderT e m) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

imap :: ((e, i) -> a -> b) -> ReaderT e m a -> ReaderT e m b Source #

imapped :: IndexedSetter (e, i) (ReaderT e m a) (ReaderT e m b) a b Source #

(FunctorWithIndex i f, FunctorWithIndex j g) => FunctorWithIndex (i, j) (f :.: g) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

imap :: ((i, j) -> a -> b) -> (f :.: g) a -> (f :.: g) b Source #

imapped :: IndexedSetter (i, j) ((f :.: g) a) ((f :.: g) b) a b Source #

(FunctorWithIndex i f, FunctorWithIndex j g) => FunctorWithIndex (i, j) (Compose f g) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

imap :: ((i, j) -> a -> b) -> Compose f g a -> Compose f g b Source #

imapped :: IndexedSetter (i, j) (Compose f g a) (Compose f g b) a b Source #

Indexed Foldables

class Foldable f => FoldableWithIndex i f | 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.

foldMapifoldMap . const

ifoldMap :: (TraversableWithIndex i f, 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.

foldMapifoldMap . const

ifolded :: IndexedFold i (f a) a Source #

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]

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.

foldrifoldr . 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.

foldlifoldl . const

ifoldr' :: (i -> a -> b -> b) -> b -> f a -> b Source #

Strictly fold right over the elements of a structure with access to the index i.

When you don't need access to the index then Foldable is more flexible in what it accepts.

Foldableifoldr' . const

ifoldl' :: (i -> b -> a -> b) -> b -> f a -> b Source #

Fold over the elements of a structure with an index, associating to the left, but strictly.

When you don't need access to the index then foldlOf' is more flexible in what it accepts.

foldlOf' l ≡ ifoldlOf' l . const
Instances
FoldableWithIndex Int [] Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

ifoldMap :: Monoid m => (Int -> a -> m) -> [a] -> m Source #

ifolded :: IndexedFold Int [a] a Source #

ifoldr :: (Int -> a -> b -> b) -> b -> [a] -> b Source #

ifoldl :: (Int -> b -> a -> b) -> b -> [a] -> b Source #

ifoldr' :: (Int -> a -> b -> b) -> b -> [a] -> b Source #

ifoldl' :: (Int -> b -> a -> b) -> b -> [a] -> b Source #

FoldableWithIndex Int ZipList Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

ifoldMap :: Monoid m => (Int -> a -> m) -> ZipList a -> m Source #

ifolded :: IndexedFold Int (ZipList a) a 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 Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

ifoldMap :: Monoid m => (Int -> a -> m) -> NonEmpty a -> m Source #

ifolded :: IndexedFold Int (NonEmpty a) a 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 Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

ifoldMap :: Monoid m => (Int -> a -> m) -> IntMap a -> m Source #

ifolded :: IndexedFold Int (IntMap a) a 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 Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

ifoldMap :: Monoid m => (Int -> a -> m) -> Seq a -> m Source #

ifolded :: IndexedFold Int (Seq a) a Source #

ifoldr :: (Int -> a -> b -> b) -> b -> Seq a -> b Source #

ifoldl :: (Int -> b -> a -> b) -> b -> Seq a -> b Source #

ifoldr' :: (Int -> a -> b -> b) -> b -> Seq a -> b Source #

ifoldl' :: (Int -> b -> a -> b) -> b -> Seq a -> b Source #

FoldableWithIndex Int Vector Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

ifoldMap :: Monoid m => (Int -> a -> m) -> Vector a -> m Source #

ifolded :: IndexedFold Int (Vector a) a Source #

ifoldr :: (Int -> a -> b -> b) -> b -> Vector a -> b Source #

ifoldl :: (Int -> b -> a -> b) -> b -> Vector a -> b Source #

ifoldr' :: (Int -> a -> b -> b) -> b -> Vector a -> b Source #

ifoldl' :: (Int -> b -> a -> b) -> b -> Vector a -> b Source #

FoldableWithIndex Int Deque Source # 
Instance details

Defined in Control.Lens.Internal.Deque

Methods

ifoldMap :: Monoid m => (Int -> a -> m) -> Deque a -> m Source #

ifolded :: IndexedFold Int (Deque a) a Source #

ifoldr :: (Int -> a -> b -> b) -> b -> Deque a -> b Source #

ifoldl :: (Int -> b -> a -> b) -> b -> Deque a -> b Source #

ifoldr' :: (Int -> a -> b -> b) -> b -> Deque a -> b Source #

ifoldl' :: (Int -> b -> a -> b) -> b -> Deque a -> b Source #

FoldableWithIndex () Maybe Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

ifoldMap :: Monoid m => (() -> a -> m) -> Maybe a -> m Source #

ifolded :: IndexedFold () (Maybe a) a 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 () Par1 Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

ifoldMap :: Monoid m => (() -> a -> m) -> Par1 a -> m Source #

ifolded :: IndexedFold () (Par1 a) a Source #

ifoldr :: (() -> a -> b -> b) -> b -> Par1 a -> b Source #

ifoldl :: (() -> b -> a -> b) -> b -> Par1 a -> b Source #

ifoldr' :: (() -> a -> b -> b) -> b -> Par1 a -> b Source #

ifoldl' :: (() -> b -> a -> b) -> b -> Par1 a -> b Source #

FoldableWithIndex () Identity Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

ifoldMap :: Monoid m => (() -> a -> m) -> Identity a -> m Source #

ifolded :: IndexedFold () (Identity a) a 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 #

Ix i => FoldableWithIndex i (Array i) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

ifoldMap :: Monoid m => (i -> a -> m) -> Array i a -> m Source #

ifolded :: IndexedFold i (Array i a) a 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 i (Level i) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

ifoldMap :: Monoid m => (i -> a -> m) -> Level i a -> m Source #

ifolded :: IndexedFold i (Level i a) a Source #

ifoldr :: (i -> a -> b -> b) -> b -> Level i a -> b Source #

ifoldl :: (i -> b -> a -> b) -> b -> Level i a -> b Source #

ifoldr' :: (i -> a -> b -> b) -> b -> Level i a -> b Source #

ifoldl' :: (i -> b -> a -> b) -> b -> Level i a -> b Source #

FoldableWithIndex k (HashMap k) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

ifoldMap :: Monoid m => (k -> a -> m) -> HashMap k a -> m Source #

ifolded :: IndexedFold k (HashMap k a) a Source #

ifoldr :: (k -> a -> b -> b) -> b -> HashMap k a -> b Source #

ifoldl :: (k -> b -> a -> b) -> b -> HashMap k a -> b Source #

ifoldr' :: (k -> a -> b -> b) -> b -> HashMap k a -> b Source #

ifoldl' :: (k -> b -> a -> b) -> b -> HashMap k a -> b Source #

FoldableWithIndex k (Map k) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

ifoldMap :: Monoid m => (k -> a -> m) -> Map k a -> m Source #

ifolded :: IndexedFold k (Map k a) a Source #

ifoldr :: (k -> a -> b -> b) -> b -> Map k a -> b Source #

ifoldl :: (k -> b -> a -> b) -> b -> Map k a -> b 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) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

ifoldMap :: Monoid m => (k -> a -> m) -> (k, a) -> m Source #

ifolded :: IndexedFold k (k, a) a Source #

ifoldr :: (k -> a -> b -> b) -> b -> (k, a) -> b Source #

ifoldl :: (k -> b -> a -> b) -> b -> (k, a) -> b Source #

ifoldr' :: (k -> a -> b -> b) -> b -> (k, a) -> b Source #

ifoldl' :: (k -> b -> a -> b) -> b -> (k, a) -> b Source #

FoldableWithIndex Void (V1 :: Type -> Type) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

ifoldMap :: Monoid m => (Void -> a -> m) -> V1 a -> m Source #

ifolded :: IndexedFold Void (V1 a) a Source #

ifoldr :: (Void -> a -> b -> b) -> b -> V1 a -> b Source #

ifoldl :: (Void -> b -> a -> b) -> b -> V1 a -> b Source #

ifoldr' :: (Void -> a -> b -> b) -> b -> V1 a -> b Source #

ifoldl' :: (Void -> b -> a -> b) -> b -> V1 a -> b Source #

FoldableWithIndex Void (U1 :: Type -> Type) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

ifoldMap :: Monoid m => (Void -> a -> m) -> U1 a -> m Source #

ifolded :: IndexedFold Void (U1 a) a Source #

ifoldr :: (Void -> a -> b -> b) -> b -> U1 a -> b Source #

ifoldl :: (Void -> b -> a -> b) -> b -> U1 a -> b Source #

ifoldr' :: (Void -> a -> b -> b) -> b -> U1 a -> b Source #

ifoldl' :: (Void -> b -> a -> b) -> b -> U1 a -> b Source #

FoldableWithIndex Void (Proxy :: Type -> Type) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

ifoldMap :: Monoid m => (Void -> a -> m) -> Proxy a -> m Source #

ifolded :: IndexedFold Void (Proxy a) a 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 () (Tagged a) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

ifoldMap :: Monoid m => (() -> a0 -> m) -> Tagged a a0 -> m Source #

ifolded :: IndexedFold () (Tagged a a0) a0 Source #

ifoldr :: (() -> a0 -> b -> b) -> b -> Tagged a a0 -> b Source #

ifoldl :: (() -> b -> a0 -> b) -> b -> Tagged a a0 -> b Source #

ifoldr' :: (() -> a0 -> b -> b) -> b -> Tagged a a0 -> b Source #

ifoldl' :: (() -> b -> a0 -> b) -> b -> Tagged a a0 -> b Source #

FoldableWithIndex i f => FoldableWithIndex i (Rec1 f) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

ifoldMap :: Monoid m => (i -> a -> m) -> Rec1 f a -> m Source #

ifolded :: IndexedFold i (Rec1 f a) a 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 m => FoldableWithIndex i (IdentityT m) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

ifoldMap :: Monoid m0 => (i -> a -> m0) -> IdentityT m a -> m0 Source #

ifolded :: IndexedFold i (IdentityT m a) a 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) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

ifoldMap :: Monoid m => (i -> a -> m) -> Reverse f a -> m Source #

ifolded :: IndexedFold i (Reverse f a) a 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 i f => FoldableWithIndex i (Backwards f) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

ifoldMap :: Monoid m => (i -> a -> m) -> Backwards f a -> m Source #

ifolded :: IndexedFold i (Backwards f a) a 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 Void (Const e :: Type -> Type) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

ifoldMap :: Monoid m => (Void -> a -> m) -> Const e a -> m Source #

ifolded :: IndexedFold Void (Const e a) a 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) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

ifoldMap :: Monoid m => (Void -> a -> m) -> Constant e a -> m Source #

ifolded :: IndexedFold Void (Constant e a) a 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 (Magma i t b) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

ifoldMap :: Monoid m => (i -> a -> m) -> Magma i t b a -> m Source #

ifolded :: IndexedFold i (Magma i t b a) a Source #

ifoldr :: (i -> a -> b0 -> b0) -> b0 -> Magma i t b a -> b0 Source #

ifoldl :: (i -> b0 -> a -> b0) -> b0 -> Magma i t b a -> b0 Source #

ifoldr' :: (i -> a -> b0 -> b0) -> b0 -> Magma i t b a -> b0 Source #

ifoldl' :: (i -> b0 -> a -> b0) -> b0 -> Magma i t b a -> b0 Source #

FoldableWithIndex Void (K1 i c :: Type -> Type) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

ifoldMap :: Monoid m => (Void -> a -> m) -> K1 i c a -> m Source #

ifolded :: IndexedFold Void (K1 i c a) a 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 Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

ifoldMap :: Monoid m => ([Int] -> a -> m) -> Tree a -> m Source #

ifolded :: IndexedFold [Int] (Tree a) a 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 [i] (Cofree f) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

ifoldMap :: Monoid m => ([i] -> a -> m) -> Cofree f a -> m Source #

ifolded :: IndexedFold [i] (Cofree f a) a Source #

ifoldr :: ([i] -> a -> b -> b) -> b -> Cofree f a -> b Source #

ifoldl :: ([i] -> b -> a -> b) -> b -> Cofree f a -> b Source #

ifoldr' :: ([i] -> a -> b -> b) -> b -> Cofree f a -> b Source #

ifoldl' :: ([i] -> b -> a -> b) -> b -> Cofree f a -> b Source #

FoldableWithIndex i f => FoldableWithIndex [i] (Free f) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

ifoldMap :: Monoid m => ([i] -> a -> m) -> Free f a -> m Source #

ifolded :: IndexedFold [i] (Free f a) a Source #

ifoldr :: ([i] -> a -> b -> b) -> b -> Free f a -> b Source #

ifoldl :: ([i] -> b -> a -> b) -> b -> Free f a -> b Source #

ifoldr' :: ([i] -> a -> b -> b) -> b -> Free f a -> b Source #

ifoldl' :: ([i] -> b -> a -> b) -> b -> Free f a -> b Source #

(FoldableWithIndex i f, FoldableWithIndex j g) => FoldableWithIndex (Either i j) (f :+: g) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

ifoldMap :: Monoid m => (Either i j -> a -> m) -> (f :+: g) a -> m Source #

ifolded :: IndexedFold (Either i j) ((f :+: g) a) a 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) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

ifoldMap :: Monoid m => (Either i j -> a -> m) -> (f :*: g) a -> m Source #

ifolded :: IndexedFold (Either i j) ((f :*: g) a) a 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) (Product f g) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

ifoldMap :: Monoid m => (Either i j -> a -> m) -> Product f g a -> m Source #

ifolded :: IndexedFold (Either i j) (Product f g a) a 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) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

ifoldMap :: Monoid m => (Either i j -> a -> m) -> Sum f g a -> m Source #

ifolded :: IndexedFold (Either i j) (Sum f g a) a 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 (i, j) (f :.: g) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

ifoldMap :: Monoid m => ((i, j) -> a -> m) -> (f :.: g) a -> m Source #

ifolded :: IndexedFold (i, j) ((f :.: g) a) a 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 #

(FoldableWithIndex i f, FoldableWithIndex j g) => FoldableWithIndex (i, j) (Compose f g) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

ifoldMap :: Monoid m => ((i, j) -> a -> m) -> Compose f g a -> m Source #

ifolded :: IndexedFold (i, j) (Compose f g a) a 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 #

Indexed Foldable Combinators

iany :: FoldableWithIndex i f => (i -> a -> Bool) -> f a -> Bool Source #

Return whether or not any element in a container satisfies a predicate, with access to the index i.

When you don't need access to the index then any is more flexible in what it accepts.

anyiany . const

iall :: FoldableWithIndex i f => (i -> a -> Bool) -> f a -> Bool Source #

Return whether or not all elements in a container satisfy a predicate, with access to the index i.

When you don't need access to the index then all is more flexible in what it accepts.

alliall . const

inone :: FoldableWithIndex i f => (i -> a -> Bool) -> f a -> Bool Source #

Return whether or not none of the elements in a container satisfy a predicate, with access to the index i.

When you don't need access to the index then none is more flexible in what it accepts.

noneinone . const
inone f ≡ not . iany f

none :: Foldable f => (a -> Bool) -> f a -> Bool Source #

Determines whether no elements of the structure satisfy the predicate.

none f ≡ not . any f

itraverse_ :: (FoldableWithIndex i t, Applicative f) => (i -> a -> f b) -> t a -> f () Source #

Traverse elements with access to the index i, discarding the results.

When you don't need access to the index then traverse_ is more flexible in what it accepts.

traverse_ l = itraverse . const

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_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

imapM_ :: (FoldableWithIndex i t, Monad m) => (i -> a -> m b) -> t a -> m () Source #

Run monadic actions for each target of an IndexedFold or IndexedTraversal with access to the index, discarding the results.

When you don't need access to the index then mapMOf_ is more flexible in what it accepts.

mapM_imapM . const

iforM_ :: (FoldableWithIndex i t, Monad m) => t a -> (i -> a -> m b) -> m () Source #

Run monadic actions for each target of an IndexedFold or IndexedTraversal with access to the index, discarding the results (with the arguments flipped).

iforM_flip imapM_

When you don't need access to the index then forMOf_ is more flexible in what it accepts.

forMOf_ l a ≡ iforMOf l a . const

iconcatMap :: FoldableWithIndex i f => (i -> a -> [b]) -> f a -> [b] Source #

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.

concatMapiconcatMap . const
iconcatMapifoldMap

ifind :: FoldableWithIndex i f => (i -> a -> Bool) -> f a -> Maybe (i, a) Source #

Searches a container with a predicate that is also supplied the index, returning the left-most element of the structure matching the predicate, or Nothing if there is no such element.

When you don't need access to the index then find is more flexible in what it accepts.

findifind . const

ifoldrM :: (FoldableWithIndex i f, Monad m) => (i -> a -> b -> m b) -> b -> f a -> m b Source #

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

When you don't need access to the index then foldrM is more flexible in what it accepts.

foldrMifoldrM . const

ifoldlM :: (FoldableWithIndex i f, Monad m) => (i -> b -> a -> m b) -> b -> f a -> m b Source #

Monadic fold over the elements of a structure with an index, associating to the left.

When you don't need access to the index then foldlM is more flexible in what it accepts.

foldlMifoldlM . const

itoList :: FoldableWithIndex i f => f a -> [(i, a)] Source #

Extract the key-value pairs from a structure.

When you don't need access to the indices in the result, then toList is more flexible in what it accepts.

toListmap snd . itoList

Converting to Folds

withIndex :: (Indexable i p, Functor f) => p (i, s) (f (j, t)) -> Indexed i s (f t) Source #

Fold 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")]

asIndex :: (Indexable i p, Contravariant f, Functor f) => p i (f i) -> Indexed i s (f s) Source #

When composed with an IndexedFold or IndexedTraversal this yields an (Indexed) Fold of the indices.

Restricting by Index

indices :: (Indexable i p, Applicative f) => (i -> Bool) -> Optical' p (Indexed i) f a a Source #

This 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"]

index :: (Indexable i p, Eq i, Applicative f) => i -> Optical' p (Indexed i) f a a Source #

This allows you to filter an IndexedFold, IndexedGetter, IndexedTraversal or IndexedLens based on an index.

>>> ["hello","the","world","!!!"]^?traversed.index 2
Just "world"

Indexed Traversables

class (FunctorWithIndex i t, FoldableWithIndex i t, Traversable t) => TraversableWithIndex i t | t -> i where Source #

A 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)

Minimal complete definition

Nothing

Methods

itraverse :: Applicative f => (i -> a -> f b) -> t a -> f (t b) Source #

Traverse an indexed container.

itraverseitraverseOf itraversed

itraverse :: (i ~ Int, Applicative f) => (i -> a -> f b) -> t a -> f (t b) Source #

Traverse an indexed container.

itraverseitraverseOf itraversed

itraversed :: IndexedTraversal i (t a) (t b) a b Source #

Instances
TraversableWithIndex Int [] Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

itraverse :: Applicative f => (Int -> a -> f b) -> [a] -> f [b] Source #

itraversed :: IndexedTraversal Int [a] [b] a b Source #

TraversableWithIndex Int ZipList Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

itraverse :: Applicative f => (Int -> a -> f b) -> ZipList a -> f (ZipList b) Source #

itraversed :: IndexedTraversal Int (ZipList a) (ZipList b) a b Source #

TraversableWithIndex Int NonEmpty Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

itraverse :: Applicative f => (Int -> a -> f b) -> NonEmpty a -> f (NonEmpty b) Source #

itraversed :: IndexedTraversal Int (NonEmpty a) (NonEmpty b) a b Source #

TraversableWithIndex Int IntMap Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

itraverse :: Applicative f => (Int -> a -> f b) -> IntMap a -> f (IntMap b) Source #

itraversed :: IndexedTraversal Int (IntMap a) (IntMap b) a b Source #

TraversableWithIndex Int Seq Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

itraverse :: Applicative f => (Int -> a -> f b) -> Seq a -> f (Seq b) Source #

itraversed :: IndexedTraversal Int (Seq a) (Seq b) a b Source #

TraversableWithIndex Int Vector Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

itraverse :: Applicative f => (Int -> a -> f b) -> Vector a -> f (Vector b) Source #

itraversed :: IndexedTraversal Int (Vector a) (Vector b) a b Source #

TraversableWithIndex Int Deque Source # 
Instance details

Defined in Control.Lens.Internal.Deque

Methods

itraverse :: Applicative f => (Int -> a -> f b) -> Deque a -> f (Deque b) Source #

itraversed :: IndexedTraversal Int (Deque a) (Deque b) a b Source #

TraversableWithIndex () Maybe Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

itraverse :: Applicative f => (() -> a -> f b) -> Maybe a -> f (Maybe b) Source #

itraversed :: IndexedTraversal () (Maybe a) (Maybe b) a b Source #

TraversableWithIndex () Par1 Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

itraverse :: Applicative f => (() -> a -> f b) -> Par1 a -> f (Par1 b) Source #

itraversed :: IndexedTraversal () (Par1 a) (Par1 b) a b Source #

TraversableWithIndex () Identity Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

itraverse :: Applicative f => (() -> a -> f b) -> Identity a -> f (Identity b) Source #

itraversed :: IndexedTraversal () (Identity a) (Identity b) a b Source #

Ix i => TraversableWithIndex i (Array i) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

itraverse :: Applicative f => (i -> a -> f b) -> Array i a -> f (Array i b) Source #

itraversed :: IndexedTraversal i (Array i a) (Array i b) a b Source #

TraversableWithIndex i (Level i) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

itraverse :: Applicative f => (i -> a -> f b) -> Level i a -> f (Level i b) Source #

itraversed :: IndexedTraversal i (Level i a) (Level i b) a b Source #

TraversableWithIndex k (HashMap k) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

itraverse :: Applicative f => (k -> a -> f b) -> HashMap k a -> f (HashMap k b) Source #

itraversed :: IndexedTraversal k (HashMap k a) (HashMap k b) a b Source #

TraversableWithIndex k (Map k) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

itraverse :: Applicative f => (k -> a -> f b) -> Map k a -> f (Map k b) Source #

itraversed :: IndexedTraversal k (Map k a) (Map k b) a b Source #

TraversableWithIndex k ((,) k) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

itraverse :: Applicative f => (k -> a -> f b) -> (k, a) -> f (k, b) Source #

itraversed :: IndexedTraversal k (k, a) (k, b) a b Source #

TraversableWithIndex Void (V1 :: Type -> Type) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

itraverse :: Applicative f => (Void -> a -> f b) -> V1 a -> f (V1 b) Source #

itraversed :: IndexedTraversal Void (V1 a) (V1 b) a b Source #

TraversableWithIndex Void (U1 :: Type -> Type) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

itraverse :: Applicative f => (Void -> a -> f b) -> U1 a -> f (U1 b) Source #

itraversed :: IndexedTraversal Void (U1 a) (U1 b) a b Source #

TraversableWithIndex Void (Proxy :: Type -> Type) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

itraverse :: Applicative f => (Void -> a -> f b) -> Proxy a -> f (Proxy b) Source #

itraversed :: IndexedTraversal Void (Proxy a) (Proxy b) a b Source #

TraversableWithIndex () (Tagged a) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

itraverse :: Applicative f => (() -> a0 -> f b) -> Tagged a a0 -> f (Tagged a b) Source #

itraversed :: IndexedTraversal () (Tagged a a0) (Tagged a b) a0 b Source #

TraversableWithIndex i f => TraversableWithIndex i (Rec1 f) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

itraverse :: Applicative f0 => (i -> a -> f0 b) -> Rec1 f a -> f0 (Rec1 f b) Source #

itraversed :: IndexedTraversal i (Rec1 f a) (Rec1 f b) a b Source #

TraversableWithIndex i m => TraversableWithIndex i (IdentityT m) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

itraverse :: Applicative f => (i -> a -> f b) -> IdentityT m a -> f (IdentityT m b) Source #

itraversed :: IndexedTraversal i (IdentityT m a) (IdentityT m b) a b Source #

TraversableWithIndex i f => TraversableWithIndex i (Reverse f) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

itraverse :: Applicative f0 => (i -> a -> f0 b) -> Reverse f a -> f0 (Reverse f b) Source #

itraversed :: IndexedTraversal i (Reverse f a) (Reverse f b) a b Source #

TraversableWithIndex i f => TraversableWithIndex i (Backwards f) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

itraverse :: Applicative f0 => (i -> a -> f0 b) -> Backwards f a -> f0 (Backwards f b) Source #

itraversed :: IndexedTraversal i (Backwards f a) (Backwards f b) a b Source #

TraversableWithIndex Void (Const e :: Type -> Type) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

itraverse :: Applicative f => (Void -> a -> f b) -> Const e a -> f (Const e b) Source #

itraversed :: IndexedTraversal Void (Const e a) (Const e b) a b Source #

TraversableWithIndex Void (Constant e :: Type -> Type) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

itraverse :: Applicative f => (Void -> a -> f b) -> Constant e a -> f (Constant e b) Source #

itraversed :: IndexedTraversal Void (Constant e a) (Constant e b) a b Source #

TraversableWithIndex i (Magma i t b) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

itraverse :: Applicative f => (i -> a -> f b0) -> Magma i t b a -> f (Magma i t b b0) Source #

itraversed :: IndexedTraversal i (Magma i t b a) (Magma i t b b0) a b0 Source #

TraversableWithIndex Void (K1 i c :: Type -> Type) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

itraverse :: Applicative f => (Void -> a -> f b) -> K1 i c a -> f (K1 i c b) Source #

itraversed :: IndexedTraversal Void (K1 i c a) (K1 i c b) a b Source #

TraversableWithIndex [Int] Tree Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

itraverse :: Applicative f => ([Int] -> a -> f b) -> Tree a -> f (Tree b) Source #

itraversed :: IndexedTraversal [Int] (Tree a) (Tree b) a b Source #

TraversableWithIndex i f => TraversableWithIndex [i] (Cofree f) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

itraverse :: Applicative f0 => ([i] -> a -> f0 b) -> Cofree f a -> f0 (Cofree f b) Source #

itraversed :: IndexedTraversal [i] (Cofree f a) (Cofree f b) a b Source #

TraversableWithIndex i f => TraversableWithIndex [i] (Free f) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

itraverse :: Applicative f0 => ([i] -> a -> f0 b) -> Free f a -> f0 (Free f b) Source #

itraversed :: IndexedTraversal [i] (Free f a) (Free f b) a b Source #

(TraversableWithIndex i f, TraversableWithIndex j g) => TraversableWithIndex (Either i j) (f :+: g) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

itraverse :: Applicative f0 => (Either i j -> a -> f0 b) -> (f :+: g) a -> f0 ((f :+: g) b) Source #

itraversed :: IndexedTraversal (Either i j) ((f :+: g) a) ((f :+: g) b) a b Source #

(TraversableWithIndex i f, TraversableWithIndex j g) => TraversableWithIndex (Either i j) (f :*: g) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

itraverse :: Applicative f0 => (Either i j -> a -> f0 b) -> (f :*: g) a -> f0 ((f :*: g) b) Source #

itraversed :: IndexedTraversal (Either i j) ((f :*: g) a) ((f :*: g) b) a b Source #

(TraversableWithIndex i f, TraversableWithIndex j g) => TraversableWithIndex (Either i j) (Product f g) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

itraverse :: Applicative f0 => (Either i j -> a -> f0 b) -> Product f g a -> f0 (Product f g b) Source #

itraversed :: IndexedTraversal (Either i j) (Product f g a) (Product f g b) a b Source #

(TraversableWithIndex i f, TraversableWithIndex j g) => TraversableWithIndex (Either i j) (Sum f g) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

itraverse :: Applicative f0 => (Either i j -> a -> f0 b) -> Sum f g a -> f0 (Sum f g b) Source #

itraversed :: IndexedTraversal (Either i j) (Sum f g a) (Sum f g b) a b Source #

(TraversableWithIndex i f, TraversableWithIndex j g) => TraversableWithIndex (i, j) (f :.: g) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

itraverse :: Applicative f0 => ((i, j) -> a -> f0 b) -> (f :.: g) a -> f0 ((f :.: g) b) Source #

itraversed :: IndexedTraversal (i, j) ((f :.: g) a) ((f :.: g) b) a b Source #

(TraversableWithIndex i f, TraversableWithIndex j g) => TraversableWithIndex (i, j) (Compose f g) Source # 
Instance details

Defined in Control.Lens.Indexed

Methods

itraverse :: Applicative f0 => ((i, j) -> a -> f0 b) -> Compose f g a -> f0 (Compose f g b) Source #

itraversed :: IndexedTraversal (i, j) (Compose f g a) (Compose f g b) a b Source #

Indexed Traversable Combinators

ifor :: (TraversableWithIndex i t, Applicative f) => t a -> (i -> a -> f b) -> f (t b) Source #

Traverse with an index (and the arguments flipped).

for a ≡ ifor a . const
iforflip itraverse

imapM :: (TraversableWithIndex i t, Monad m) => (i -> a -> m b) -> t a -> m (t b) Source #

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.

mapMimapM . const

iforM :: (TraversableWithIndex i t, Monad m) => t a -> (i -> a -> m b) -> m (t b) Source #

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).

forM a ≡ iforM a . const
iforMflip imapM

imapAccumR :: TraversableWithIndex i t => (i -> s -> a -> (s, b)) -> s -> t a -> (s, t b) Source #

Generalizes mapAccumR to add access to the index.

imapAccumROf accumulates state from right to left.

mapAccumRimapAccumR . const

imapAccumL :: TraversableWithIndex i t => (i -> s -> a -> (s, b)) -> s -> t a -> (s, t b) Source #

Generalizes mapAccumL to add access to the index.

imapAccumLOf accumulates state from left to right.

mapAccumLOfimapAccumL . const

Indexed Folds with Reified Monoid

ifoldMapBy :: FoldableWithIndex i t => (r -> r -> r) -> r -> (i -> a -> r) -> t a -> r Source #

ifoldMapByOf :: IndexedFold i t a -> (r -> r -> r) -> r -> (i -> a -> r) -> t -> r Source #

Indexed Traversals with Reified Applicative

itraverseBy :: TraversableWithIndex i t => (forall x. x -> f x) -> (forall x y. f (x -> y) -> f x -> f y) -> (i -> a -> f b) -> t a -> f (t b) Source #

itraverseByOf :: IndexedTraversal i s t a b -> (forall x. x -> f x) -> (forall x y. f (x -> y) -> f x -> f y) -> (i -> a -> f b) -> s -> f t Source #