HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Moduleoptics-core-0.4.1.1Haskell2010

Optics.IxLens

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.

  • 5 types
  • 8 values

Formation

2 declarations

Introduction

1 declaration
valueilens :: (s -> (i, a)) -> (s -> b -> t) -> IxLens i s t a b
#

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

0 declarations

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

4 declarations
valuedevoid :: IxLens' i Void a
#

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

Example1 expression
set (mapped % devoid) 1 [][]
Example1 expression
over (_Just % devoid) abs NothingNothing
valueifst :: IxLens i (a, i) (b, i) a b
#

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

See isnd for examples.

valueisnd :: IxLens i (i, a) (i, b) a b
#

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

Example1 expression
iview isnd ('a', True)('a',True)

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

Example1 expression
:t itraversed :: IxTraversal i (i, a) (i, b) a bitraversed :: IxTraversal i (i, a) (i, b) a b  :: IxTraversal i (i, a) (i, b) a b

Subtyping

1 declaration
datadata A_Lens
#

Tag for a lens.

Instances35ReversibleOptic, Is, ArrowOptic, JoinKinds, IxOptic, ToReadOnly, …

van Laarhoven encoding

5 declarations
typetype IxLensVL i s t a b = forall (f :: Type -> Type). Functor f => (i -> a -> f b) -> s -> f t
#

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

typetype IxLensVL' i s a = IxLensVL i s s a a
#

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

valueilensVL :: IxLensVL i s t a b -> IxLens i s t a b
#

Build an indexed lens from the van Laarhoven representation.