optics-core-0.4: Optics as an abstract interface: core definitions
Safe HaskellNone
LanguageHaskell2010

Optics.IxLens

Description

An IxLens is an indexed version of a Lens. See the "Indexed optics" section of the overview documentation in the Optics module of the main optics package for more details on indexed optics.

Synopsis

Formation

type IxLens i s t a b = Optic A_Lens (WithIx i) s t a b Source #

Type synonym for a type-modifying indexed lens.

type IxLens' i s a = Optic' A_Lens (WithIx i) s a Source #

Type synonym for a type-preserving indexed lens.

Introduction

ilens :: (s -> (i, a)) -> (s -> b -> t) -> IxLens i s t a b Source #

Build an indexed lens from a getter and a setter.

If you want to build an IxLens from the van Laarhoven representation, use ilensVL.

Elimination

An IxLens is in particular an IxGetter and an IxSetter, therefore you can specialise types to obtain:

iview :: IxLens i s t a b -> s -> (i, a)
iover :: IxLens i s t a b -> (i -> a -> b) -> s -> t
iset  :: IxLens i s t a b -> (i      -> b) -> s -> t

Additional introduction forms

chosen :: IxLens (Either () ()) (Either a a) (Either b b) a b Source #

Focus on both sides of an Either.

devoid :: IxLens' i Void a Source #

There is an indexed field for every type in the Void.

>>> set (mapped % devoid) 1 []
[]
>>> over (_Just % devoid) abs Nothing
Nothing

ifst :: IxLens i (a, i) (b, i) a b Source #

Indexed _1 with other half of a pair as an index.

See isnd for examples.

Since: 0.4

isnd :: IxLens i (i, a) (i, b) a b Source #

Indexed _2 with other half of a pair as an index. Specialized version of itraversed to pairs, which can be IxLens.

>>> iview isnd ('a', True)
('a',True)

That is not possible with itraversed, because it is an IxTraversal.

>>> :t itraversed :: IxTraversal i (i, a) (i, b) a b
itraversed :: IxTraversal i (i, a) (i, b) a b
  :: IxTraversal i (i, a) (i, b) a b

Since: 0.4

Subtyping

data A_Lens :: OpticKind Source #

Tag for a lens.

Instances

Instances details
ReversibleOptic A_Lens Source # 
Instance details

Defined in Optics.Re

Associated Types

type ReversedOptic A_Lens = (r :: Type) Source #

Methods

re :: forall (is :: IxList) s t a b. AcceptsEmptyIndices "re" is => Optic A_Lens is s t a b -> Optic (ReversedOptic A_Lens) is b a t s Source #

Is A_Lens A_Fold Source # 
Instance details

Defined in Optics.Internal.Optic.Subtyping

Methods

implies :: forall (p :: Type -> Type -> Type -> Type) r. (Constraints A_Lens p => r) -> Constraints A_Fold p => r Source #

Is A_Lens An_AffineFold Source # 
Instance details

Defined in Optics.Internal.Optic.Subtyping

Methods

implies :: forall (p :: Type -> Type -> Type -> Type) r. (Constraints A_Lens p => r) -> Constraints An_AffineFold p => r Source #

Is A_Lens A_Getter Source # 
Instance details

Defined in Optics.Internal.Optic.Subtyping

Methods

implies :: forall (p :: Type -> Type -> Type -> Type) r. (Constraints A_Lens p => r) -> Constraints A_Getter p => r Source #

Is A_Lens A_Setter Source # 
Instance details

Defined in Optics.Internal.Optic.Subtyping

Methods

implies :: forall (p :: Type -> Type -> Type -> Type) r. (Constraints A_Lens p => r) -> Constraints A_Setter p => r Source #

Is A_Lens A_Traversal Source # 
Instance details

Defined in Optics.Internal.Optic.Subtyping

Methods

implies :: forall (p :: Type -> Type -> Type -> Type) r. (Constraints A_Lens p => r) -> Constraints A_Traversal p => r Source #

Is A_Lens An_AffineTraversal Source # 
Instance details

Defined in Optics.Internal.Optic.Subtyping

Methods

implies :: forall (p :: Type -> Type -> Type -> Type) r. (Constraints A_Lens p => r) -> Constraints An_AffineTraversal p => r Source #

Is An_Iso A_Lens Source # 
Instance details

Defined in Optics.Internal.Optic.Subtyping

Methods

implies :: forall (p :: Type -> Type -> Type -> Type) r. (Constraints An_Iso p => r) -> Constraints A_Lens p => r Source #

Arrow arr => ArrowOptic A_Lens arr Source # 
Instance details

Defined in Optics.Arrow

Methods

overA :: forall (is :: IxList) s t a b. Optic A_Lens is s t a b -> arr a b -> arr s t Source #

JoinKinds A_Fold A_Lens A_Fold Source # 
Instance details

Defined in Optics.Internal.Optic.Subtyping

Methods

joinKinds :: forall (p :: Type -> Type -> Type -> Type) r. ((Constraints A_Fold p, Constraints A_Lens p) => r) -> Constraints A_Fold p => r Source #

JoinKinds An_AffineFold A_Lens An_AffineFold Source # 
Instance details

Defined in Optics.Internal.Optic.Subtyping

Methods

joinKinds :: forall (p :: Type -> Type -> Type -> Type) r. ((Constraints An_AffineFold p, Constraints A_Lens p) => r) -> Constraints An_AffineFold p => r Source #

JoinKinds A_Getter A_Lens A_Getter Source # 
Instance details

Defined in Optics.Internal.Optic.Subtyping

Methods

joinKinds :: forall (p :: Type -> Type -> Type -> Type) r. ((Constraints A_Getter p, Constraints A_Lens p) => r) -> Constraints A_Getter p => r Source #

JoinKinds A_ReversedPrism A_Lens A_Getter Source # 
Instance details

Defined in Optics.Internal.Optic.Subtyping

Methods

joinKinds :: forall (p :: Type -> Type -> Type -> Type) r. ((Constraints A_ReversedPrism p, Constraints A_Lens p) => r) -> Constraints A_Getter p => r Source #

JoinKinds A_Setter A_Lens A_Setter Source # 
Instance details

Defined in Optics.Internal.Optic.Subtyping

Methods

joinKinds :: forall (p :: Type -> Type -> Type -> Type) r. ((Constraints A_Setter p, Constraints A_Lens p) => r) -> Constraints A_Setter p => r Source #

JoinKinds A_Traversal A_Lens A_Traversal Source # 
Instance details

Defined in Optics.Internal.Optic.Subtyping

Methods

joinKinds :: forall (p :: Type -> Type -> Type -> Type) r. ((Constraints A_Traversal p, Constraints A_Lens p) => r) -> Constraints A_Traversal p => r Source #

JoinKinds An_AffineTraversal A_Lens An_AffineTraversal Source # 
Instance details

Defined in Optics.Internal.Optic.Subtyping

Methods

joinKinds :: forall (p :: Type -> Type -> Type -> Type) r. ((Constraints An_AffineTraversal p, Constraints A_Lens p) => r) -> Constraints An_AffineTraversal p => r Source #

JoinKinds A_Prism A_Lens An_AffineTraversal Source # 
Instance details

Defined in Optics.Internal.Optic.Subtyping

Methods

joinKinds :: forall (p :: Type -> Type -> Type -> Type) r. ((Constraints A_Prism p, Constraints A_Lens p) => r) -> Constraints An_AffineTraversal p => r Source #

JoinKinds A_Lens A_Fold A_Fold Source # 
Instance details

Defined in Optics.Internal.Optic.Subtyping

Methods

joinKinds :: forall (p :: Type -> Type -> Type -> Type) r. ((Constraints A_Lens p, Constraints A_Fold p) => r) -> Constraints A_Fold p => r Source #

JoinKinds A_Lens An_AffineFold An_AffineFold Source # 
Instance details

Defined in Optics.Internal.Optic.Subtyping

Methods

joinKinds :: forall (p :: Type -> Type -> Type -> Type) r. ((Constraints A_Lens p, Constraints An_AffineFold p) => r) -> Constraints An_AffineFold p => r Source #

JoinKinds A_Lens A_Getter A_Getter Source # 
Instance details

Defined in Optics.Internal.Optic.Subtyping

Methods

joinKinds :: forall (p :: Type -> Type -> Type -> Type) r. ((Constraints A_Lens p, Constraints A_Getter p) => r) -> Constraints A_Getter p => r Source #

JoinKinds A_Lens A_ReversedPrism A_Getter Source # 
Instance details

Defined in Optics.Internal.Optic.Subtyping

Methods

joinKinds :: forall (p :: Type -> Type -> Type -> Type) r. ((Constraints A_Lens p, Constraints A_ReversedPrism p) => r) -> Constraints A_Getter p => r Source #

JoinKinds A_Lens A_Setter A_Setter Source # 
Instance details

Defined in Optics.Internal.Optic.Subtyping

Methods

joinKinds :: forall (p :: Type -> Type -> Type -> Type) r. ((Constraints A_Lens p, Constraints A_Setter p) => r) -> Constraints A_Setter p => r Source #

JoinKinds A_Lens A_Traversal A_Traversal Source # 
Instance details

Defined in Optics.Internal.Optic.Subtyping

Methods

joinKinds :: forall (p :: Type -> Type -> Type -> Type) r. ((Constraints A_Lens p, Constraints A_Traversal p) => r) -> Constraints A_Traversal p => r Source #

JoinKinds A_Lens An_AffineTraversal An_AffineTraversal Source # 
Instance details

Defined in Optics.Internal.Optic.Subtyping

Methods

joinKinds :: forall (p :: Type -> Type -> Type -> Type) r. ((Constraints A_Lens p, Constraints An_AffineTraversal p) => r) -> Constraints An_AffineTraversal p => r Source #

JoinKinds A_Lens A_Prism An_AffineTraversal Source # 
Instance details

Defined in Optics.Internal.Optic.Subtyping

Methods

joinKinds :: forall (p :: Type -> Type -> Type -> Type) r. ((Constraints A_Lens p, Constraints A_Prism p) => r) -> Constraints An_AffineTraversal p => r Source #

JoinKinds A_Lens A_Lens A_Lens Source # 
Instance details

Defined in Optics.Internal.Optic.Subtyping

Methods

joinKinds :: forall (p :: Type -> Type -> Type -> Type) r. ((Constraints A_Lens p, Constraints A_Lens p) => r) -> Constraints A_Lens p => r Source #

JoinKinds A_Lens An_Iso A_Lens Source # 
Instance details

Defined in Optics.Internal.Optic.Subtyping

Methods

joinKinds :: forall (p :: Type -> Type -> Type -> Type) r. ((Constraints A_Lens p, Constraints An_Iso p) => r) -> Constraints A_Lens p => r Source #

JoinKinds An_Iso A_Lens A_Lens Source # 
Instance details

Defined in Optics.Internal.Optic.Subtyping

Methods

joinKinds :: forall (p :: Type -> Type -> Type -> Type) r. ((Constraints An_Iso p, Constraints A_Lens p) => r) -> Constraints A_Lens p => r Source #

ToReadOnly A_Lens s t a b Source # 
Instance details

Defined in Optics.ReadOnly

Associated Types

type ReadOnlyOptic A_Lens Source #

Methods

getting :: forall (is :: IxList). Optic A_Lens is s t a b -> Optic' (ReadOnlyOptic A_Lens) is s a Source #

IxOptic A_Lens s t a b Source # 
Instance details

Defined in Optics.Indexed.Core

Methods

noIx :: forall (is :: IxList). NonEmptyIndices is => Optic A_Lens is s t a b -> Optic A_Lens NoIx s t a b Source #

(Functor f, f ~ g, s ~ t, a ~ b) => MappingOptic A_Lens f g s t a b Source # 
Instance details

Defined in Optics.Mapping

Associated Types

type MappedOptic A_Lens Source #

Methods

mapping :: forall (is :: IxList). AcceptsEmptyIndices "mapping" is => Optic A_Lens is s t a b -> Optic (MappedOptic A_Lens) is (f s) (g t) (f a) (g b) Source #

type ReversedOptic A_Lens Source # 
Instance details

Defined in Optics.Re

type ReadOnlyOptic A_Lens Source # 
Instance details

Defined in Optics.ReadOnly

type MappedOptic A_Lens Source # 
Instance details

Defined in Optics.Mapping

van Laarhoven encoding

type IxLensVL i s t a b = forall f. Functor f => (i -> a -> f b) -> s -> f t Source #

Type synonym for a type-modifying van Laarhoven indexed lens.

type IxLensVL' i s a = IxLensVL i s s a a Source #

Type synonym for a type-preserving van Laarhoven indexed lens.

ilensVL :: IxLensVL i s t a b -> IxLens i s t a b Source #

Build an indexed lens from the van Laarhoven representation.

toIxLensVL :: (Is k A_Lens, is `HasSingleIndex` i) => Optic k is s t a b -> IxLensVL i s t a b Source #

Convert an indexed lens to its van Laarhoven representation.

withIxLensVL :: (Is k A_Lens, is `HasSingleIndex` i) => Optic k is s t a b -> (IxLensVL i s t a b -> r) -> r Source #

Work with an indexed lens in the van Laarhoven representation.