| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
Proarrow.Optic.MonoidalTraversal
Description
The monoidal traversal optic and its free-profunctor apparatus. The mutually recursive
TravFl/MonTravFl flavor classes and their leaf instances live in
Proarrow.Optic.Traversal. A MonoidalTraversal distributes any
StrongDistributiveProfunctor with no product-strength requirement; the profunctor-class
encoding PTraversal converts to and from it via toPTraversal/fromPTraversal, the latter
through the generic carrier , made an SDP here by generators (the Day
halves, the tensor-action witness ExOptic MonTravFl/RepCorep( and the coproduct prism).ActionAt Tensor _)
Synopsis
- type MonoidalTraversal (s :: k) (t :: k) (a :: k) (b :: k) = Optic (Prostrong (MonTravFl :: (k +-> k) -> (k +-> k) -> Constraint)) s t a b
- type MonoidalTraversal' (s :: k) (a :: k) = MonoidalTraversal s s a a
- exBeside :: forall {k} (w :: FLAVOR k k) (a :: k) (b :: k) (s1 :: k) (t1 :: k) (s2 :: k) (t2 :: k). (Monoidal k, forall (p1 :: k +-> k) (p2 :: k +-> k) (q1 :: k +-> k) (q2 :: k +-> k). (w p1 q1, w p2 q2, Profunctor p1, Profunctor p2, Profunctor q1, Profunctor q2) => w (Beside p1 p2) (CoBeside q1 q2)) => ExOptic w a b s1 t1 -> ExOptic w a b s2 t2 -> ExOptic w a b (s1 ** s2) (t1 ** t2)
- exBesideSum :: forall {k} (w :: FLAVOR k k) (a :: k) (b :: k) (s1 :: k) (t1 :: k) (s2 :: k) (t2 :: k). (HasBinaryCoproducts k, forall (p1 :: k +-> k) (p2 :: k +-> k) (q1 :: k +-> k) (q2 :: k +-> k). (w p1 q1, w p2 q2, Profunctor p1, Profunctor p2, Profunctor q1, Profunctor q2) => w (BesideSum p1 p2) (CoBesideSum q1 q2)) => ExOptic w a b s1 t1 -> ExOptic w a b s2 t2 -> ExOptic w a b (s1 || s2) (t1 || t2)
- fromPTraversal :: forall {k} (s :: k) (t :: k) (a :: k) (b :: k). (Distributive k, CopyDiscard k, SymMonoidal k) => PTraversal s t a b -> MonoidalTraversal s t a b
- monTraverseOf :: forall {k} (c :: (k -> k -> Type) -> Constraint) (s :: k) (t :: k) (a :: k) (b :: k) p. (Distributive k, StrongDistributiveProfunctor p, (Ob a, Ob b) => c (ExOptic (MonTravFl :: (k +-> k) -> (k +-> k) -> Constraint) a b)) => Optic c s t a b -> p a b -> p s t
- type PTraversal (s :: j) (t :: j) (a :: j) (b :: j) = Optic (StrongDistributiveProfunctor :: (j +-> j) -> Constraint) s t a b
- type PTraversal' (s :: j) (a :: j) = PTraversal s s a a
- toPTraversal :: forall {k} (s :: k) (t :: k) (a :: k) (b :: k). Distributive k => MonoidalTraversal s t a b -> PTraversal s t a b
- type PTraversalFull (s :: j) (t :: j) (a :: j) (b :: j) = Optic ((StrongDistributiveProfunctor :: (j +-> j) -> Constraint) :&&: Strong (ProdAction :: j -> (PROD j, j) -> Type)) s t a b
- traversal :: forall {k} (s :: k) (t :: k) (a :: k) (b :: k). (Distributive k, CopyDiscard k, SymMonoidal k, HasProducts k, Ob a, Ob b, Ob s, Ob t) => (forall (r :: k +-> k). (StrongDistributiveProfunctor r, Strong (ProdAction :: k -> (PROD k, k) -> Type) r) => r a b -> r s t) -> Traversal s t a b
- toPTraversalFull :: forall {k} (s :: k) (t :: k) (a :: k) (b :: k). Distributive k => Traversal s t a b -> PTraversalFull s t a b
- v1Optic :: PTraversal (V1 a) (V1 a') a a'
- u1Optic :: PTraversal (U1 a) (U1 a') a a'
- par1Optic :: PTraversal (Par1 a) (Par1 a') a a'
- rec1Optic :: PTraversal (f a) (f a') a a' -> PTraversal (Rec1 f a) (Rec1 f a') a a'
- m1Optic :: forall f a a' i (k :: Meta). PTraversal (f a) (f a') a a' -> PTraversal (M1 i k f a) (M1 i k f a') a a'
- k1Optic :: PTraversal (K1 i k a) (K1 i k a') a a'
- plusOptic :: PTraversal (p a) (p a') a a' -> PTraversal (q a) (q a') a a' -> PTraversal ((p :+: q) a) ((p :+: q) a') a a'
- multOptic :: PTraversal (p a) (p a') a a' -> PTraversal (q a) (q a') a a' -> PTraversal ((p :*: q) a) ((p :*: q) a') a a'
- compOptic :: PTraversal (p (q a)) (p (q a')) (q a) (q a') -> PTraversal (q a) (q a') a a' -> PTraversal ((p :.: q) a) ((p :.: q) a') a a'
Documentation
type MonoidalTraversal (s :: k) (t :: k) (a :: k) (b :: k) = Optic (Prostrong (MonTravFl :: (k +-> k) -> (k +-> k) -> Constraint)) s t a b Source Github #
type MonoidalTraversal' (s :: k) (a :: k) = MonoidalTraversal s s a a Source Github #
The generic carrier is a strong distributive profunctor, by generators
exBeside :: forall {k} (w :: FLAVOR k k) (a :: k) (b :: k) (s1 :: k) (t1 :: k) (s2 :: k) (t2 :: k). (Monoidal k, forall (p1 :: k +-> k) (p2 :: k +-> k) (q1 :: k +-> k) (q2 :: k +-> k). (w p1 q1, w p2 q2, Profunctor p1, Profunctor p2, Profunctor q1, Profunctor q2) => w (Beside p1 p2) (CoBeside q1 q2)) => ExOptic w a b s1 t1 -> ExOptic w a b s2 t2 -> ExOptic w a b (s1 ** s2) (t1 ** t2) Source Github #
exBesideSum :: forall {k} (w :: FLAVOR k k) (a :: k) (b :: k) (s1 :: k) (t1 :: k) (s2 :: k) (t2 :: k). (HasBinaryCoproducts k, forall (p1 :: k +-> k) (p2 :: k +-> k) (q1 :: k +-> k) (q2 :: k +-> k). (w p1 q1, w p2 q2, Profunctor p1, Profunctor p2, Profunctor q1, Profunctor q2) => w (BesideSum p1 p2) (CoBesideSum q1 q2)) => ExOptic w a b s1 t1 -> ExOptic w a b s2 t2 -> ExOptic w a b (s1 || s2) (t1 || t2) Source Github #
fromPTraversal :: forall {k} (s :: k) (t :: k) (a :: k) (b :: k). (Distributive k, CopyDiscard k, SymMonoidal k) => PTraversal s t a b -> MonoidalTraversal s t a b Source Github #
The other half of the equivalence between the encodings: instantiate the profunctor-class
traversal at , an SDP by the instances above. Its tensor strength
comes from the tensor-action witness ExOptic MonTravFl a b, so this needs only
Rep (ActionAt Tensor _)CopyDiscard, already demanded by the coproduct prism,
and no Cartesian. So Mat and FinRel qualify, but
LINEAR, which cannot discard, does not. A Traversal follows since MonTravFl is a subflavor
of TravFl.
monTraverseOf :: forall {k} (c :: (k -> k -> Type) -> Constraint) (s :: k) (t :: k) (a :: k) (b :: k) p. (Distributive k, StrongDistributiveProfunctor p, (Ob a, Ob b) => c (ExOptic (MonTravFl :: (k +-> k) -> (k +-> k) -> Constraint) a b)) => Optic c s t a b -> p a b -> p s t Source Github #
Like traverseOf, but for a MonoidalTraversal: distributes any
StrongDistributiveProfunctor with no product-strength requirement on the carrier. Every non-lens traversal (prism,
Traversable functor, ...) is a monoidal traversal, so this accepts carriers like
that are tensor-strong but not product-strong.Writer w
Accepts any encoding (cf. traverseOf): a PTraversal works directly,
as does a (%)-composite.
type PTraversal (s :: j) (t :: j) (a :: j) (b :: j) = Optic (StrongDistributiveProfunctor :: (j +-> j) -> Constraint) s t a b Source Github #
A traversal in the profunctor-class-flavored encoding (cf. PIso), used by
the GHC.Generics combinators below. Equivalent to Traversal via toPTraversal and
fromPTraversal.
type PTraversal' (s :: j) (a :: j) = PTraversal s s a a Source Github #
toPTraversal :: forall {k} (s :: k) (t :: k) (a :: k) (b :: k). Distributive k => MonoidalTraversal s t a b -> PTraversal s t a b Source Github #
Half of the equivalence between the two traversal encodings: eliminate the existential
witnesses with travP at the caller's profunctor.
type PTraversalFull (s :: j) (t :: j) (a :: j) (b :: j) = Optic ((StrongDistributiveProfunctor :: (j +-> j) -> Constraint) :&&: Strong (ProdAction :: j -> (PROD j, j) -> Type)) s t a b Source Github #
A full traversal in the profunctor-class encoding: distributes any profunctor carrying both
distributive strength and product strength, the constraint travP demands. This is
the Traversal analog of PTraversal, which drops the product strength (all it needs for a
MonoidalTraversal). Equivalent to Traversal via toPTraversalFull and traversal.
traversal :: forall {k} (s :: k) (t :: k) (a :: k) (b :: k). (Distributive k, CopyDiscard k, SymMonoidal k, HasProducts k, Ob a, Ob b, Ob s, Ob t) => (forall (r :: k +-> k). (StrongDistributiveProfunctor r, Strong (ProdAction :: k -> (PROD k, k) -> Type) r) => r a b -> r s t) -> Traversal s t a b Source Github #
Build a Traversal from its profunctor-class form, by instantiating the
rank-2 function at the generic carrier (a ExOptic TravFl a bStrongDistributiveProfunctor
and , unlike Strong ProdAction, since ExOptic MonTravFl a bTravFl contains the
product-lens witness). The Traversal analog of fromPTraversal.
toPTraversalFull :: forall {k} (s :: k) (t :: k) (a :: k) (b :: k). Distributive k => Traversal s t a b -> PTraversalFull s t a b Source Github #
Eliminate a Traversal to its profunctor-class form (the analog of toPTraversal): run travP
at the caller's profunctor.
rec1Optic :: PTraversal (f a) (f a') a a' -> PTraversal (Rec1 f a) (Rec1 f a') a a' Source Github #
m1Optic :: forall f a a' i (k :: Meta). PTraversal (f a) (f a') a a' -> PTraversal (M1 i k f a) (M1 i k f a') a a' Source Github #
plusOptic :: PTraversal (p a) (p a') a a' -> PTraversal (q a) (q a') a a' -> PTraversal ((p :+: q) a) ((p :+: q) a') a a' Source Github #
multOptic :: PTraversal (p a) (p a') a a' -> PTraversal (q a) (q a') a a' -> PTraversal ((p :*: q) a) ((p :*: q) a') a a' Source Github #
compOptic :: PTraversal (p (q a)) (p (q a')) (q a) (q a') -> PTraversal (q a) (q a') a a' -> PTraversal ((p :.: q) a) ((p :.: q) a') a a' Source Github #
Orphan instances
| (Monoidal k, Ob a, Ob b, Flavor w, forall (x :: k). Ob x => w (Rep (ActionAt (Tensor :: k -> (k, k) -> Type) x)) (Corep (ActionAt (Tensor :: k -> (k, k) -> Type) x))) => Strong (Tensor :: k -> (k, k) -> Type) (ExOptic w a b :: k -> k -> Type) Source Github # | |
| (Monoidal k, Ob a, Ob b, w (UnitW :: k -> k -> Type) (CoUnitW :: k -> k -> Type), forall (p1 :: k -> k -> Type) (p2 :: k -> k -> Type) (q1 :: k -> k -> Type) (q2 :: k -> k -> Type). (w p1 q1, w p2 q2, Profunctor p1, Profunctor p2, Profunctor q1, Profunctor q2) => w (Beside p1 p2) (CoBeside q1 q2)) => MonoidalProfunctor (ExOptic w a b :: k -> k -> Type) Source Github # | |
| (CategoryOf k, Flavor w, forall (t :: k +-> k). (Traversable t, Representable t) => w t (RepCostar t)) => Traversing (ExOptic w a b :: k -> k -> Type) Source Github # | The generic carrier absorbs a traversable witness by composing the pair |
| (HasCoproducts k, Ob a, Ob b, Flavor w, forall (t :: k). Ob t => w (Rep (Coproduct t)) (Corep (Coproduct t))) => Strong (CoprodAction :: k -> (COPROD k, k) -> Type) (ExOptic w a b :: k -> k -> Type) Source Github # | |
| (HasProducts k, Ob a, Ob b, Flavor w, forall (s :: k). Ob s => w (Rep (Product s)) (Corep (Product s))) => Strong (ProdAction :: k -> (PROD k, k) -> Type) (ExOptic w a b :: k -> k -> Type) Source Github # | |
| (HasCoproducts k, Ob a, Ob b, w (ZeroW :: k -> k -> Type) (CoZeroW :: k -> k -> Type), forall (p1 :: k -> k -> Type) (p2 :: k -> k -> Type) (q1 :: k -> k -> Type) (q2 :: k -> k -> Type). (w p1 q1, w p2 q2, Profunctor p1, Profunctor p2, Profunctor q1, Profunctor q2) => w (BesideSum p1 p2) (CoBesideSum q1 q2)) => MonoidalProfunctor (Coprod (ExOptic w a b) :: COPROD k -> COPROD k -> Type) Source Github # | |