optics-core-0.3.0.1: Optics as an abstract interface: core definitions

Safe HaskellNone
LanguageHaskell2010

Optics.ReversedLens

Contents

Description

A ReversedLens is a backwards Lens, i.e. a ReversedLens s t a b is equivalent to a Lens b a t s. These are typically produced by calling re on a Lens. They are distinguished from a Review so that re . re on a Lens returns a Lens.

Synopsis

Formation

type ReversedLens s t a b = Optic A_ReversedLens NoIx s t a b Source #

Type synonym for a type-modifying reversed lens.

type ReversedLens' t b = Optic' A_ReversedLens NoIx t b Source #

Type synonym for a type-preserving reversed lens.

Introduction

There is no canonical introduction form for ReversedLens, but you can use re to construct one from a Lens:

(\ f g -> re (lens f g)) :: (b -> t) -> (b -> s -> a) -> ReversedLens s t a b

Elimination

A ReversedLens is a Review, so you can specialise types to obtain:

review :: ReversedLens' s a -> a -> s

There is no corresponding optic kind for a backwards Setter, but a reversed set is definable using re:

set . re :: ReversedLens s t a b -> s -> b -> a

Computation

review   $ re (lens f g) ≡ f
set . re $ re (lens f g) ≡ g

Subtyping

data A_ReversedLens :: OpticKind Source #

Tag for a reversed lens.

Instances
ReversibleOptic A_ReversedLens Source # 
Instance details

Defined in Optics.Re

Associated Types

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

Methods

re :: AcceptsEmptyIndices "re" is => Optic A_ReversedLens is s t a b -> Optic (ReversedOptic A_ReversedLens) is b a t s Source #

Is A_ReversedLens A_Review Source # 
Instance details

Defined in Optics.Internal.Optic.Subtyping

Is An_Iso A_ReversedLens Source # 
Instance details

Defined in Optics.Internal.Optic.Subtyping

(Functor f, f ~ g, s ~ t, a ~ b) => MappingOptic A_ReversedLens f g s t a b Source # 
Instance details

Defined in Optics.Mapping

Associated Types

type MappedOptic A_ReversedLens :: Type Source #

Methods

mapping :: AcceptsEmptyIndices "mapping" is => Optic A_ReversedLens is s t a b -> Optic (MappedOptic A_ReversedLens) is (f s) (g t) (f a) (g b) Source #

type ReversedOptic A_ReversedLens Source # 
Instance details

Defined in Optics.Re

type MappedOptic A_ReversedLens Source # 
Instance details

Defined in Optics.Mapping