HORIZON HASKELLDocslts/ghc-10.0.x77a86622026-10-31Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 77a8662 · 2026-10-31

Moduleoptics-core-0.4.2Haskell2010

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.

Contents
  1. Formation
  2. Introduction
  3. Elimination
  4. Additional introduction forms
  5. Subtyping
  6. van Laarhoven encoding
Synopsis
  • Packageoptics-core-0.4.2
  • Exports13
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceIxLens.hs

Formation

Introduction

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

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

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

datadata A_Lens

Tag for a lens.

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

van Laarhoven encoding

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.