proarrow
Safe HaskellNone
LanguageGHC2024

Proarrow.Optic.Lens

Description

The lens: the optic for the categorical product, with legs

Lens s t a b = (s ~> a, (s && b) ~> t)

witnessed by Rep/Corep (Product s) (LensFl / putP). The product residual is the whole source s. A lens both views and sets, sitting below Getter and AffineTraversal in the lattice. Build with lens (or from the van-Laarhoven form with lensVL), eliminate to the two legs with withLens, via the generic ExOptic carrier.

Synopsis

Documentation

class (AffineTravFl p q, GetterFl p q, GlassFl p q) => LensFl (p :: k +-> k) (q :: k +-> k) where Source Github #

Methods

putP :: forall (s :: k) (a :: k) (b :: k) (t :: k). HasBinaryProducts k => p s a -> q b t -> (s && b) ~> t Source Github #

Like affineSet, but with a weaker constraint. Lens witnesses only ever need binary products, so lenses stay usable in categories without coproducts.

Instances

Instances details
CategoryOf k => LensFl (Id :: k -> k -> Type) (Id :: k -> k -> Type) Source Github # 
Instance details

Defined in Proarrow.Optic.Lens

Methods

putP :: forall (s :: k) (a :: k) (b :: k) (t :: k). HasBinaryProducts k => Id s a -> Id b t -> (s && b) ~> t Source Github #

(HasBinaryProducts k, Ob s) => LensFl (Rep (Product s) :: k -> k -> Type) (Corep (Product s) :: k -> k -> Type) Source Github # 
Instance details

Defined in Proarrow.Optic.Lens

Methods

putP :: forall (s0 :: k) (a :: k) (b :: k) (t :: k). HasBinaryProducts k => Rep (Product s) s0 a -> Corep (Product s) b t -> (s0 && b) ~> t Source Github #

(LensFl f g, LensFl f' g') => LensFl (f :.: f' :: i -> i -> Type) (g' :.: g :: i -> i -> Type) Source Github # 
Instance details

Defined in Proarrow.Optic.Lens

Methods

putP :: forall (s :: i) (a :: i) (b :: i) (t :: i). HasBinaryProducts i => (f :.: f') s a -> (g' :.: g) b t -> (s && b) ~> t Source Github #

type Lens (s :: k) (t :: k) (a :: k) (b :: k) = Optic (Prostrong (LensFl :: (k +-> k) -> (k +-> k) -> Constraint)) s t a b Source Github #

type Lens' (s :: k) (a :: k) = Lens s s a a Source Github #

lens :: forall {k} (s :: k) (t :: k) (a :: k) (b :: k). (HasBinaryProducts k, Ob b) => (s ~> a) -> ((s && b) ~> t) -> Lens s t a b Source Github #

withLens :: forall {k} (c :: (k -> k -> Type) -> Constraint) (s :: k) (t :: k) (a :: k) (b :: k) r. (HasBinaryProducts k, (Ob a, Ob b) => c (ExOptic (LensFl :: (k +-> k) -> (k +-> k) -> Constraint) a b)) => Optic c s t a b -> ((s ~> a) -> ((s && b) ~> t) -> r) -> r Source Github #

Eliminate any optic that is at least an iso and at most a lens to its two legs, in either encoding: run it at its witness pair (ExOptic LensFl, via withLegs) and read the legs off with getP and putP.

type LensVL s t a b = forall (f :: Type -> Type). Functor f => (a -> f b) -> s -> f t Source Github #

toLensVL :: Lens s t a b -> LensVL s t a b Source Github #

lensVL :: LensVL s t a b -> Lens s t a b Source Github #