lens-5.0.1: Lenses, Folds and Traversals
Copyright (C) 2012-2016 Edward Kmett
License BSD-style (see the file LICENSE)
Maintainer Edward Kmett <ekmett@gmail.com>
Stability experimental
Portability non-portable
Safe Haskell Trustworthy
Language Haskell2010

Control.Lens.Internal.Indexed

Description

Internal implementation details for Indexed lens-likes

Synopsis

An Indexed Profunctor

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

Instances details
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 Source #

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

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

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

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

ArrowChoice ( Indexed i) Source #
Instance details

Defined in Control.Lens.Internal.Indexed

ArrowApply ( Indexed i) Source #
Instance details

Defined in Control.Lens.Internal.Indexed

Methods

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

ArrowLoop ( Indexed i) Source #
Instance details

Defined in Control.Lens.Internal.Indexed

Methods

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

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

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

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

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

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

Representable ( Indexed i) Source #
Instance details

Defined in Control.Lens.Internal.Indexed

Associated Types

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

Corepresentable ( Indexed i) Source #
Instance details

Defined in Control.Lens.Internal.Indexed

Associated Types

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

Choice ( Indexed i) Source #
Instance details

Defined in Control.Lens.Internal.Indexed

Closed ( Indexed i) Source #
Instance details

Defined in Control.Lens.Internal.Indexed

Methods

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

Strong ( Indexed i) Source #
Instance details

Defined in Control.Lens.Internal.Indexed

Methods

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

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

Costrong ( Indexed i) Source #
Instance details

Defined in Control.Lens.Internal.Indexed

Methods

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

unsecond :: Indexed i (d, a) (d, b) -> Indexed i a b 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 #

Bizarre ( Indexed Int ) Mafic Source #
Instance details

Defined in Control.Lens.Internal.Magma

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

Defined in Control.Lens.Internal.Indexed

Methods

id :: forall (a :: k). Indexed i a a Source #

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

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

Defined in Control.Lens.Internal.Indexed

Methods

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

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

Defined in Control.Lens.Internal.Magma

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

Monad ( Indexed i a) Source #
Instance details

Defined in Control.Lens.Internal.Indexed

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

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

MonadFix ( Indexed i a) Source #
Instance details

Defined in Control.Lens.Internal.Indexed

Methods

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

Applicative ( Indexed i a) Source #
Instance details

Defined in Control.Lens.Internal.Indexed

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

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

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

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

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

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

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

Classes

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

Instances details
Conjoined ReifiedGetter Source #
Instance details

Defined in Control.Lens.Reified

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 #

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

Instances details
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 #

Indexing

newtype Indexing f a Source #

Applicative composition of State Int with a Functor , used by indexed .

Constructors

Indexing

Fields

Instances

Instances details
Functor f => Functor ( Indexing f) Source #
Instance details

Defined in Control.Lens.Internal.Indexed

Applicative f => Applicative ( Indexing f) Source #
Instance details

Defined in Control.Lens.Internal.Indexed

Contravariant f => Contravariant ( Indexing f) Source #
Instance details

Defined in Control.Lens.Internal.Indexed

Apply f => Apply ( Indexing f) Source #
Instance details

Defined in Control.Lens.Internal.Indexed

Semigroup (f a) => Semigroup ( Indexing f a) Source #
Instance details

Defined in Control.Lens.Internal.Indexed

Monoid (f a) => Monoid ( Indexing f a) Source #
>>> "cat" ^@.. (folded <> folded)
[(0,'c'),(1,'a'),(2,'t'),(0,'c'),(1,'a'),(2,'t')]
>>> "cat" ^@.. indexing (folded <> folded)
[(0,'c'),(1,'a'),(2,'t'),(3,'c'),(4,'a'),(5,'t')]
Instance details

Defined in Control.Lens.Internal.Indexed

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

64-bit Indexing

newtype Indexing64 f a Source #

Constructors

Indexing64

Fields

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

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.