Safe Haskell | None |
---|---|
Language | Haskell2010 |
Some optics can be reversed with
re
. This is mainly useful to invert
Iso
s:
>>>
let _Identity = iso runIdentity Identity
>>>
view (_1 % re _Identity) ('x', "yz")
Identity 'x'
Yet we can use a
Lens
as a
Review
too:
>>>
review (re _1) ('x', "yz")
'x'
In the following diagram, red arrows illustrate how
re
transforms optics.
The
ReversedLens
and
ReversedPrism
optic kinds are backwards versions of
Lens
and
Prism
respectively, and are present so
that
does not change the optic kind.
re
.
re
Synopsis
-
class
ReversibleOptic
k
where
- type ReversedOptic k = r | r -> k
- re :: "re" `AcceptsEmptyIndices` is => Optic k is s t a b -> Optic ( ReversedOptic k) is b a t s
Documentation
class ReversibleOptic k where Source #
Class for optics that can be
re
versed.
type ReversedOptic k = r | r -> k Source #
Injective type family that maps an optic kind to the optic kind produced
by
re
versing it.
ReversedOptic
An_Iso
=An_Iso
ReversedOptic
A_Prism
=A_ReversedPrism
ReversedOptic
A_ReversedPrism
=A_Prism
ReversedOptic
A_Lens
=A_ReversedLens
ReversedOptic
A_ReversedLens
=A_Lens
ReversedOptic
A_Getter
=A_Review
ReversedOptic
A_Review
=A_Getter
re :: "re" `AcceptsEmptyIndices` is => Optic k is s t a b -> Optic ( ReversedOptic k) is b a t s Source #
Reverses optics, turning around
Iso
into
Iso
,
Prism
into
ReversedPrism
(and
back),
Lens
into
ReversedLens
(and back)
and
Getter
into
Review
(and back).
Instances
ReversibleOptic A_Review Source # | |
ReversibleOptic A_ReversedLens Source # | |
Defined in Optics.Re type ReversedOptic A_ReversedLens = (r :: Type ) Source # re :: forall (is :: IxList ) s t a b. AcceptsEmptyIndices "re" is => Optic A_ReversedLens is s t a b -> Optic ( ReversedOptic A_ReversedLens ) is b a t s Source # |
|
ReversibleOptic A_Getter Source # | |
ReversibleOptic A_ReversedPrism Source # | |
Defined in Optics.Re type ReversedOptic A_ReversedPrism = (r :: Type ) Source # re :: forall (is :: IxList ) s t a b. AcceptsEmptyIndices "re" is => Optic A_ReversedPrism is s t a b -> Optic ( ReversedOptic A_ReversedPrism ) is b a t s Source # |
|
ReversibleOptic A_Prism Source # | |
ReversibleOptic A_Lens Source # | |
ReversibleOptic An_Iso Source # | |