Safe Haskell | None |
---|---|

Language | Haskell2010 |

## Synopsis

- type IxLens i s t a b = Optic A_Lens (WithIx i) s t a b
- type IxLens' i s a = Optic' A_Lens (WithIx i) s a
- ilens :: (s -> (i, a)) -> (s -> b -> t) -> IxLens i s t a b
- devoid :: IxLens' i Void a
- data A_Lens :: OpticKind
- type IxLensVL i s t a b = forall f. Functor f => (i -> a -> f b) -> s -> f t
- type IxLensVL' i s a = IxLensVL i s s a a
- ilensVL :: IxLensVL i s t a b -> IxLens i s t a b
- toIxLensVL :: (Is k A_Lens, is `HasSingleIndex` i) => Optic k is s t a b -> IxLensVL i s t a b
- withIxLensVL :: (Is k A_Lens, is `HasSingleIndex` i) => Optic k is s t a b -> (IxLensVL i s t a b -> r) -> r

# 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

# 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

devoid :: IxLens' i Void a Source #

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

.

`>>>`

[]`set (mapped % devoid) 1 []`

`>>>`

Nothing`over (_Just % devoid) abs Nothing`

# Subtyping

data A_Lens :: OpticKind Source #

Tag for a lens.

## Instances

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