Safe Haskell | Safe-Inferred |
---|---|
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
- chosen :: IxLens (Either () ()) (Either a a) (Either b b) a b
- devoid :: IxLens' i Void a
- ifst :: IxLens i (a, i) (b, i) a b
- isnd :: IxLens i (i, a) (i, b) a b
- 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 -> tiset
::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
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
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.