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) (LensRes / 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 Shop carrier.

Synopsis

Documentation

class (AffineTravRes p q, GetterRes p q) => LensRes (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 an honest constraint: lens witnesses only ever need binary products, so lenses stay usable in categories without coproducts.

Instances

Instances details
CategoryOf k => LensRes (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) => LensRes (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 #

(LensRes f g, LensRes f' g') => LensRes (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 (LensRes :: (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 #

data Shop (a :: k) (b :: k) (s :: k) (t :: k) where Source Github #

The eliminating carrier for lenses: a lens's two legs, as a profunctor in s/t.

Constructors

Shop :: forall {k} (a :: k) (b :: k) (s :: k) (t :: k). (Ob a, Ob b) => (s ~> a) -> ((s && b) ~> t) -> Shop a b s t 

Instances

Instances details
(HasBinaryProducts k, Ob a, Ob b, SubFlavor w (LensRes :: (k +-> k) -> (k +-> k) -> Constraint)) => Prostrong (w :: FLAVOR k k) (Shop a b :: k -> k -> Type) Source Github #

Any flavor whose optics have lens legs has strength for the Shop carrier.

Instance details

Defined in Proarrow.Optic.Lens

Methods

proact :: forall (f :: k +-> k) (g :: k +-> k). (w f g, Profunctor f, Profunctor g) => ((f :.: Shop a b) :.: g) :~> Shop a b Source Github #

(HasBinaryProducts k, Ob a, Ob b) => Profunctor (Shop a b :: k -> k -> Type) Source Github # 
Instance details

Defined in Proarrow.Optic.Lens

Methods

dimap :: forall (c :: k) (a0 :: k) (b0 :: k) (d :: k). (c ~> a0) -> (b0 ~> d) -> Shop a b a0 b0 -> Shop a b c d Source Github #

lmap :: forall (c :: k) (a0 :: k) (b0 :: k). (c ~> a0) -> Shop a b a0 b0 -> Shop a b c b0 Source Github #

rmap :: forall (b0 :: k) (d :: k) (a0 :: k). (b0 ~> d) -> Shop a b a0 b0 -> Shop a b a0 d Source Github #

(\\) :: forall (a0 :: k) (b0 :: k) r. ((Ob a0, Ob b0) => r) -> Shop a b a0 b0 -> r 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 (Shop 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: Prostrong-flavored optics via SubFlavor w LensRes (through the bridge instance above), profunctor-class-flavored optics via their class instance for Shop.

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 #