| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
Proarrow.Optic.MonoidalLens
Description
The monoidal lens: the coend optic for the tensor action with a comonoidal residual,
MonoidalLens s t a b = exists m. Comonoid m => (s ~> m ** a, m ** b ~> t)
The residual m is carried through the tensor, and being a Comonoid it can be discarded
() and copied -- which is exactly what a lens's counit :: m ~> Unitget needs. So a
monoidal lens is a genuine lens (it views, sets, folds and traverses), and it sits below
MonoidalTraversal and Getter in the
lattice, mirroring the ordinary Lens below
AffineTraversal:
Lens <: { Getter, AffineTraversal } -- product residual
MonoidalLens <: { Getter, MonoidalTraversal } -- comonoidal tensor residualCrucially it asks Comonoid of the residual only, not
CopyDiscard of the whole category: it works in every
CopyDiscard category (there every object is a comonoid) and in genuinely non-cartesian ones
like LINEAR for the residuals that are comonoids (the duplicable Ur objects). The ordinary
Lens is the tensor = product specialization, where the residual is
recoverable from s by projection.
Synopsis
- data LensW (m :: k) (s :: k) (a :: k) where
- data CoLensW (m :: k) (b :: k) (t :: k) where
- class (GetterRes p q, MonTravRes p q) => MonLensRes (p :: k +-> k) (q :: k +-> k) where
- type MonoidalLens (s :: k) (t :: k) (a :: k) (b :: k) = Optic (Prostrong (MonLensRes :: (k +-> k) -> (k +-> k) -> Constraint)) s t a b
- type MonoidalLens' (s :: k) (a :: k) = MonoidalLens s s a a
- monLens :: forall {k} (m :: k) (s :: k) (t :: k) (a :: k) (b :: k). (Comonoid m, Ob a, Ob b) => (s ~> (m ** a)) -> ((m ** b) ~> t) -> MonoidalLens s t a b
- data MonShop (a :: k) (b :: k) (s :: k) (t :: k) where
- withMonLens :: forall {k} (c :: (k -> k -> Type) -> Constraint) (s :: k) (t :: k) (a :: k) (b :: k) r. (Monoidal k, (Ob a, Ob b) => c (MonShop a b)) => Optic c s t a b -> (forall (m :: k). Ob m => (s ~> (m ** a)) -> ((m ** b) ~> t) -> r) -> r
Documentation
data LensW (m :: k) (s :: k) (a :: k) where Source Github #
Witness pair for a monoidal lens: the focus a sits inside m ** a with a comonoidal
residual m. Being a comonoid, m can be discarded (for get/fold) and carried (for set).
Constructors
| LensW :: forall {k} (m :: k) (a :: k) (s :: k). (Comonoid m, Ob a) => (s ~> (m ** a)) -> LensW m s a |
Instances
| Comonoid m => Profunctor (LensW m :: k -> k -> Type) Source Github # | |
Defined in Proarrow.Optic.MonoidalLens Methods dimap :: forall (c :: k) (a :: k) (b :: k) (d :: k). (c ~> a) -> (b ~> d) -> LensW m a b -> LensW m c d Source Github # lmap :: forall (c :: k) (a :: k) (b :: k). (c ~> a) -> LensW m a b -> LensW m c b Source Github # rmap :: forall (b :: k) (d :: k) (a :: k). (b ~> d) -> LensW m a b -> LensW m a d Source Github # (\\) :: forall (a :: k) (b :: k) r. ((Ob a, Ob b) => r) -> LensW m a b -> r Source Github # | |
| Comonoid m => Proadjunction (LensW m :: k -> k -> Type) (CoLensW m :: k -> k -> Type) Source Github # | |
| Comonoid m => AffineFoldRes (LensW m :: k -> k -> Type) (CoLensW m :: k -> k -> Type) Source Github # | |
Defined in Proarrow.Optic.MonoidalLens Methods previewP :: forall (s :: k) (a :: k). Bicartesian k => LensW m s a -> s ~> (a || (TerminalObject :: k)) Source Github # | |
| Comonoid m => FoldRes (LensW m :: k -> k -> Type) (CoLensW m :: k -> k -> Type) Source Github # | |
| Comonoid m => GetterRes (LensW m :: k -> k -> Type) (CoLensW m :: k -> k -> Type) Source Github # | |
| Comonoid m => MonLensRes (LensW m :: k -> k -> Type) (CoLensW m :: k -> k -> Type) Source Github # | |
| Comonoid m => SetterRes (LensW m :: k -> k -> Type) (CoLensW m :: k -> k -> Type) Source Github # | |
| Comonoid m => MonTravRes (LensW m :: k -> k -> Type) (CoLensW m :: k -> k -> Type) Source Github # | |
Defined in Proarrow.Optic.MonoidalLens | |
| Comonoid m => TravRes (LensW m :: k -> k -> Type) (CoLensW m :: k -> k -> Type) Source Github # | |
Defined in Proarrow.Optic.MonoidalLens | |
data CoLensW (m :: k) (b :: k) (t :: k) where Source Github #
Constructors
| CoLensW :: forall {k} (m :: k) (b :: k) (t :: k). (Comonoid m, Ob b) => ((m ** b) ~> t) -> CoLensW m b t |
Instances
| Comonoid m => Profunctor (CoLensW m :: k -> k -> Type) Source Github # | |
Defined in Proarrow.Optic.MonoidalLens Methods dimap :: forall (c :: k) (a :: k) (b :: k) (d :: k). (c ~> a) -> (b ~> d) -> CoLensW m a b -> CoLensW m c d Source Github # lmap :: forall (c :: k) (a :: k) (b :: k). (c ~> a) -> CoLensW m a b -> CoLensW m c b Source Github # rmap :: forall (b :: k) (d :: k) (a :: k). (b ~> d) -> CoLensW m a b -> CoLensW m a d Source Github # (\\) :: forall (a :: k) (b :: k) r. ((Ob a, Ob b) => r) -> CoLensW m a b -> r Source Github # | |
| Comonoid m => Proadjunction (LensW m :: k -> k -> Type) (CoLensW m :: k -> k -> Type) Source Github # | |
| Comonoid m => AffineFoldRes (LensW m :: k -> k -> Type) (CoLensW m :: k -> k -> Type) Source Github # | |
Defined in Proarrow.Optic.MonoidalLens Methods previewP :: forall (s :: k) (a :: k). Bicartesian k => LensW m s a -> s ~> (a || (TerminalObject :: k)) Source Github # | |
| Comonoid m => FoldRes (LensW m :: k -> k -> Type) (CoLensW m :: k -> k -> Type) Source Github # | |
| Comonoid m => GetterRes (LensW m :: k -> k -> Type) (CoLensW m :: k -> k -> Type) Source Github # | |
| Comonoid m => MonLensRes (LensW m :: k -> k -> Type) (CoLensW m :: k -> k -> Type) Source Github # | |
| Comonoid m => SetterRes (LensW m :: k -> k -> Type) (CoLensW m :: k -> k -> Type) Source Github # | |
| Comonoid m => MonTravRes (LensW m :: k -> k -> Type) (CoLensW m :: k -> k -> Type) Source Github # | |
Defined in Proarrow.Optic.MonoidalLens | |
| Comonoid m => TravRes (LensW m :: k -> k -> Type) (CoLensW m :: k -> k -> Type) Source Github # | |
Defined in Proarrow.Optic.MonoidalLens | |
class (GetterRes p q, MonTravRes p q) => MonLensRes (p :: k +-> k) (q :: k +-> k) where Source Github #
The monoidal-lens flavor: a lens whose residual is a comonoid, so it is both a
Getter and a MonoidalTraversal.
Methods
withMonLensP :: forall (s :: k) (a :: k) (b :: k) (t :: k) r. Monoidal k => p s a -> q b t -> (forall (m :: k). Ob m => (s ~> (m ** a)) -> ((m ** b) ~> t) -> r) -> r Source Github #
Recover a monoidal lens's two legs, with the (comonoidal) residual m existential.
Instances
| CategoryOf k => MonLensRes (Id :: k -> k -> Type) (Id :: k -> k -> Type) Source Github # | |
| Comonoid m => MonLensRes (LensW m :: k -> k -> Type) (CoLensW m :: k -> k -> Type) Source Github # | |
| (MonLensRes f g, MonLensRes f' g') => MonLensRes (f :.: f' :: k -> k -> Type) (g' :.: g :: k -> k -> Type) Source Github # | |
type MonoidalLens (s :: k) (t :: k) (a :: k) (b :: k) = Optic (Prostrong (MonLensRes :: (k +-> k) -> (k +-> k) -> Constraint)) s t a b Source Github #
type MonoidalLens' (s :: k) (a :: k) = MonoidalLens s s a a Source Github #
monLens :: forall {k} (m :: k) (s :: k) (t :: k) (a :: k) (b :: k). (Comonoid m, Ob a, Ob b) => (s ~> (m ** a)) -> ((m ** b) ~> t) -> MonoidalLens s t a b Source Github #
Build a monoidal lens from its two legs and a chosen comonoidal residual m.
data MonShop (a :: k) (b :: k) (s :: k) (t :: k) where Source Github #
The eliminating carrier for monoidal lenses: the two legs with the residual m existential.
Constructors
| MonShop :: forall {k} (a :: k) (b :: k) (m :: k) (s :: k) (t :: k). (Ob a, Ob b, Ob m) => (s ~> (m ** a)) -> ((m ** b) ~> t) -> MonShop a b s t |
Instances
| (Monoidal k, Ob a, Ob b, SubFlavor w (MonLensRes :: (k +-> k) -> (k +-> k) -> Constraint)) => Prostrong (w :: FLAVOR k k) (MonShop a b :: k -> k -> Type) Source Github # | Any flavor whose optics have monoidal-lens legs has strength for the |
Defined in Proarrow.Optic.MonoidalLens | |
| (Monoidal k, Ob a, Ob b) => Profunctor (MonShop a b :: k -> k -> Type) Source Github # | |
Defined in Proarrow.Optic.MonoidalLens Methods dimap :: forall (c :: k) (a0 :: k) (b0 :: k) (d :: k). (c ~> a0) -> (b0 ~> d) -> MonShop a b a0 b0 -> MonShop a b c d Source Github # lmap :: forall (c :: k) (a0 :: k) (b0 :: k). (c ~> a0) -> MonShop a b a0 b0 -> MonShop a b c b0 Source Github # rmap :: forall (b0 :: k) (d :: k) (a0 :: k). (b0 ~> d) -> MonShop a b a0 b0 -> MonShop a b a0 d Source Github # (\\) :: forall (a0 :: k) (b0 :: k) r. ((Ob a0, Ob b0) => r) -> MonShop a b a0 b0 -> r Source Github # | |
withMonLens :: forall {k} (c :: (k -> k -> Type) -> Constraint) (s :: k) (t :: k) (a :: k) (b :: k) r. (Monoidal k, (Ob a, Ob b) => c (MonShop a b)) => Optic c s t a b -> (forall (m :: k). Ob m => (s ~> (m ** a)) -> ((m ** b) ~> t) -> r) -> r Source Github #
Eliminate any optic that is at least an iso and at most a monoidal lens to its two legs,
recovering the existential residual m.