optics-core-0.4.1: Optics as an abstract interface: core definitions
Safe Haskell None
Language Haskell2010

Optics.Re

Description

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 re . re does not change the optic kind.

Synopsis

Documentation

class ReversibleOptic k where Source #

Class for optics that can be re versed.

Methods

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

Instances details
ReversibleOptic A_Review Source #
Instance details

Defined in Optics.Re

Associated Types

type ReversedOptic A_Review = (r :: Type ) Source #

Methods

re :: forall (is :: IxList ) s t a b. AcceptsEmptyIndices "re" is => Optic A_Review is s t a b -> Optic ( ReversedOptic A_Review ) is b a t s Source #

ReversibleOptic A_ReversedLens Source #
Instance details

Defined in Optics.Re

ReversibleOptic A_Getter Source #
Instance details

Defined in Optics.Re

Associated Types

type ReversedOptic A_Getter = (r :: Type ) Source #

Methods

re :: forall (is :: IxList ) s t a b. AcceptsEmptyIndices "re" is => Optic A_Getter is s t a b -> Optic ( ReversedOptic A_Getter ) is b a t s Source #

ReversibleOptic A_ReversedPrism Source #
Instance details

Defined in Optics.Re

ReversibleOptic A_Prism Source #
Instance details

Defined in Optics.Re

Associated Types

type ReversedOptic A_Prism = (r :: Type ) Source #

Methods

re :: forall (is :: IxList ) s t a b. AcceptsEmptyIndices "re" is => Optic A_Prism is s t a b -> Optic ( ReversedOptic A_Prism ) is b a t s Source #

ReversibleOptic A_Lens Source #
Instance details

Defined in Optics.Re

Associated Types

type ReversedOptic A_Lens = (r :: Type ) Source #

Methods

re :: forall (is :: IxList ) s t a b. AcceptsEmptyIndices "re" is => Optic A_Lens is s t a b -> Optic ( ReversedOptic A_Lens ) is b a t s Source #

ReversibleOptic An_Iso Source #
Instance details

Defined in Optics.Re

Associated Types

type ReversedOptic An_Iso = (r :: Type ) Source #

Methods

re :: forall (is :: IxList ) s t a b. AcceptsEmptyIndices "re" is => Optic An_Iso is s t a b -> Optic ( ReversedOptic An_Iso ) is b a t s Source #