proarrow
Safe HaskellNone
LanguageGHC2024

Proarrow.Optic.Prod

Description

A third way to combine two flavors, alongside Proarrow.Optic.Sum and Proarrow.Optic.Day: pair them up over the product of two categories via :**:.

Synopsis

Documentation

class ProdRes (w1 :: FLAVOR j1 k1) (w2 :: FLAVOR j2 k2) (p :: (k1, k2) +-> (k1, k2)) (q :: (j1, j2) +-> (j1, j2)) where Source Github #

Two flavors combine into one over the product of their (possibly heterogeneous) categories, by pairing up their witness profunctors componentwise via :**: rather than sharing a single object (:*: doesn't work here: it forces both witnesses onto the *same* index kind, so it can't combine optics over genuinely different categories/objects).

Methods

withProdP :: forall (s :: (k1, k2)) (a :: (k1, k2)) (b :: (j1, j2)) (t :: (j1, j2)) r. p s a -> q b t -> (forall (p1 :: k1 +-> k1) (p2 :: k2 +-> k2) (q1 :: j1 +-> j1) (q2 :: j2 +-> j2). (w1 p1 q1, w2 p2 q2, Profunctor p1, Profunctor p2, Profunctor q1, Profunctor q2) => p1 ((Fst :: (k1, k2) +-> k1) @ s) ((Fst :: (k1, k2) +-> k1) @ a) -> p2 ((Snd :: (k1, k2) +-> k2) @ s) ((Snd :: (k1, k2) +-> k2) @ a) -> q1 ((Fst :: (j1, j2) +-> j1) @ b) ((Fst :: (j1, j2) +-> j1) @ t) -> q2 ((Snd :: (j1, j2) +-> j2) @ b) ((Snd :: (j1, j2) +-> j2) @ t) -> r) -> r Source Github #

Recover the two component witnesses from an opaque, possibly-composite ProdRes pair. Stated via Fst/Snd rather than literal tuple patterns: the existential "middle" object introduced when recursing through a :.: composite isn't syntactically a tuple, even though (being of a product kind) it always denotes one.

Instances

Instances details
(CategoryOf k1, CategoryOf k2, CategoryOf j1, CategoryOf j2, ClosedUnder w1, ClosedUnder w2) => ProdRes (w1 :: FLAVOR j1 k1) (w2 :: FLAVOR j2 k2) (Id :: (k1, k2) -> (k1, k2) -> Type) (Id :: (j1, j2) -> (j1, j2) -> Type) Source Github # 
Instance details

Defined in Proarrow.Optic.Prod

Methods

withProdP :: forall (s :: (k1, k2)) (a :: (k1, k2)) (b :: (j1, j2)) (t :: (j1, j2)) r. Id s a -> Id b t -> (forall (p1 :: k1 +-> k1) (p2 :: k2 +-> k2) (q1 :: j1 +-> j1) (q2 :: j2 +-> j2). (w1 p1 q1, w2 p2 q2, Profunctor p1, Profunctor p2, Profunctor q1, Profunctor q2) => p1 ((Fst :: (k1, k2) +-> k1) @ s) ((Fst :: (k1, k2) +-> k1) @ a) -> p2 ((Snd :: (k1, k2) +-> k2) @ s) ((Snd :: (k1, k2) +-> k2) @ a) -> q1 ((Fst :: (j1, j2) +-> j1) @ b) ((Fst :: (j1, j2) +-> j1) @ t) -> q2 ((Snd :: (j1, j2) +-> j2) @ b) ((Snd :: (j1, j2) +-> j2) @ t) -> r) -> r Source Github #

(ProdRes w1 w2 f f', ProdRes w1 w2 g g', ClosedUnder w1, ClosedUnder w2) => ProdRes (w1 :: FLAVOR j1 k1) (w2 :: FLAVOR j2 k2) (f :.: g :: (k1, k2) -> (k1, k2) -> Type) (g' :.: f' :: (j1, j2) -> (j1, j2) -> Type) Source Github # 
Instance details

Defined in Proarrow.Optic.Prod

Methods

withProdP :: forall (s :: (k1, k2)) (a :: (k1, k2)) (b :: (j1, j2)) (t :: (j1, j2)) r. (f :.: g) s a -> (g' :.: f') b t -> (forall (p1 :: k1 +-> k1) (p2 :: k2 +-> k2) (q1 :: j1 +-> j1) (q2 :: j2 +-> j2). (w1 p1 q1, w2 p2 q2, Profunctor p1, Profunctor p2, Profunctor q1, Profunctor q2) => p1 ((Fst :: (k1, k2) +-> k1) @ s) ((Fst :: (k1, k2) +-> k1) @ a) -> p2 ((Snd :: (k1, k2) +-> k2) @ s) ((Snd :: (k1, k2) +-> k2) @ a) -> q1 ((Fst :: (j1, j2) +-> j1) @ b) ((Fst :: (j1, j2) +-> j1) @ t) -> q2 ((Snd :: (j1, j2) +-> j2) @ b) ((Snd :: (j1, j2) +-> j2) @ t) -> r) -> r Source Github #

(w1 p1 q1, w2 p2 q2, Profunctor p1, Profunctor p2, Profunctor q1, Profunctor q2) => ProdRes (w1 :: (j4 +-> j4) -> (j5 +-> j5) -> Constraint) (w2 :: (j6 +-> j6) -> (j7 +-> j7) -> Constraint) (p1 :**: p2 :: (j4, j6) -> (j4, j6) -> Type) (q1 :**: q2 :: (j5, j7) -> (j5, j7) -> Type) Source Github # 
Instance details

Defined in Proarrow.Optic.Prod

Methods

withProdP :: forall (s :: (j4, j6)) (a :: (j4, j6)) (b :: (j5, j7)) (t :: (j5, j7)) r. (p1 :**: p2) s a -> (q1 :**: q2) b t -> (forall (p10 :: j4 +-> j4) (p20 :: j6 +-> j6) (q10 :: j5 +-> j5) (q20 :: j7 +-> j7). (w1 p10 q10, w2 p20 q20, Profunctor p10, Profunctor p20, Profunctor q10, Profunctor q20) => p10 ((Fst :: (j4, j6) +-> j4) @ s) ((Fst :: (j4, j6) +-> j4) @ a) -> p20 ((Snd :: (j4, j6) +-> j6) @ s) ((Snd :: (j4, j6) +-> j6) @ a) -> q10 ((Fst :: (j5, j7) +-> j5) @ b) ((Fst :: (j5, j7) +-> j5) @ t) -> q20 ((Snd :: (j5, j7) +-> j7) @ b) ((Snd :: (j5, j7) +-> j7) @ t) -> r) -> r Source Github #

prodOptic :: forall {j1} {k1} {j2} {k2} (w1 :: FLAVOR j1 k1) (w2 :: FLAVOR j2 k2) (s1 :: k1) (t1 :: j1) (a1 :: k1) (b1 :: j1) (s2 :: k2) (t2 :: j2) (a2 :: k2) (b2 :: j2). (CompactFlavor w1, CompactFlavor w2, CategoryOf j1, CategoryOf k1, CategoryOf j2, CategoryOf k2) => Optic (Prostrong w1) s1 t1 a1 b1 -> Optic (Prostrong w2) s2 t2 a2 b2 -> Optic (Prostrong (ProdRes w1 w2)) '(s1, s2) '(t1, t2) '(a1, a2) '(b1, b2) Source Github #

withProdOptic :: forall {j1} {k1} {j2} {k2} (w1 :: FLAVOR j1 k1) (w2 :: FLAVOR j2 k2) (s1 :: k1) (t1 :: j1) (a1 :: k1) (b1 :: j1) (s2 :: k2) (t2 :: j2) (a2 :: k2) (b2 :: j2) r. (CategoryOf j1, CategoryOf k1, CategoryOf j2, CategoryOf k2, ClosedUnder w1, ClosedUnder w2) => Optic (Prostrong (ProdRes w1 w2)) '(s1, s2) '(t1, t2) '(a1, a2) '(b1, b2) -> ((Optic (Prostrong w1) s1 t1 a1 b1, Optic (Prostrong w2) s2 t2 a2 b2) -> r) -> r Source Github #

The inverse of prodOptic: split a ProdRes w1 w2-flavored optic back into its two independent halves.