| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
Proarrow.Squares
Description
Squares, specialized to profunctors: the counterpart of Proarrow.Equipment.Squares in
proarrow-equipment. Data flows rightward along representable wires; effects flow
downward along profunctor wires. Paths of profunctors are read right to left, so
[p, q, r] is drawn as r, q, p and has composite r :.: q :.: p. Paths of
Representable profunctors are read top to bottom.
vId is the identity for (===), and hId is the identity for (|||).
A square's payload is , the fold of each side's
concatenated path, instead of Fold (p +++ f) :~> Fold (g +++ q).
Proarrow.Path does the associator/unitor bookkeeping once, and since Fold f :.: Fold p :~> Fold q :.: Fold g and
Nil +++ psps both reduce to +++ Nilps, combinators with trivial legs need no unitors.
Synopsis
- data Sq (p :: Path j h) (q :: Path k i) (f :: Path h i) (g :: Path j k) where
- mapSq :: forall {j1} {h1} {i1} {k1} {j2} {h2} {k2} {i2} (ps :: Path j1 h1) (fs :: Path h1 i1) (gs :: Path j1 k1) (qs :: Path k1 i1) (ps' :: Path j2 h2) (qs' :: Path k2 i2) (fs' :: Path h2 i2) (gs' :: Path j2 k2). (Profunctor (Fold (ps +++ fs)), Profunctor (Fold (gs +++ qs)), IsPath ps', IsPath qs', IsTight fs', IsTight gs') => ((Fold (ps +++ fs) ~> Fold (gs +++ qs)) -> Fold (ps' +++ fs') ~> Fold (gs' +++ qs')) -> Sq ps qs fs gs -> Sq ps' qs' fs' gs'
- mkSquare :: forall {j} {h} {k} {i} (ps :: Path j h) (qs :: Path k i) (fs :: Path h i) (gs :: Path j k). (IsPath ps, IsPath qs, IsTight fs, IsTight gs) => (forall (a :: h) (b :: j). (Ob a, Ob b) => Fold ps a b -> Fold qs (Fold fs % a) (Fold gs % b)) -> Sq ps qs fs gs
- runSquare :: forall {j1} {j2} {k1} {k2} (ps :: Path j1 j2) (qs :: Path k1 k2) (fs :: Path j2 k2) (gs :: Path j1 k1) (a :: j2) (b :: j1). Sq ps qs fs gs -> Fold ps a b -> Fold qs (Fold fs % a) (Fold gs % b)
- parallel :: forall {j4} {j5} {k4} {k5} {j6} {j7} {k6} {k7} (p :: j4 +-> j5) (q :: k4 +-> k5) (f :: j5 +-> k5) (g :: j4 +-> k4) (p' :: j6 +-> j7) (q' :: k6 +-> k7) (f' :: j7 +-> k7) (g' :: j6 +-> k6). (Profunctor p, Profunctor q, Representable f, Representable g, Profunctor p', Profunctor q', Representable f', Representable g') => Sq (p '::: ('Nil :: Path j5 j5)) (q '::: ('Nil :: Path k5 k5)) (f '::: ('Nil :: Path k5 k5)) (g '::: ('Nil :: Path k4 k4)) -> Sq (p' '::: ('Nil :: Path j7 j7)) (q' '::: ('Nil :: Path k7 k7)) (f' '::: ('Nil :: Path k7 k7)) (g' '::: ('Nil :: Path k6 k6)) -> Sq ((p :**: p') '::: ('Nil :: Path (j5, j7) (j5, j7))) ((q :**: q') '::: ('Nil :: Path (k5, k7) (k5, k7))) ((f :**: f') '::: ('Nil :: Path (k5, k7) (k5, k7))) ((g :**: g') '::: ('Nil :: Path (k4, k6) (k4, k6)))
- hParallel :: forall {j1} {k1} {j2} {k2} (f :: j1 +-> k1) (g :: j1 +-> k1) (h :: j2 +-> k2) (i :: j2 +-> k2). (Representable f, Representable g, Representable h, Representable i) => Sq ('Nil :: Path j1 j1) ('Nil :: Path k1 k1) (f '::: ('Nil :: Path k1 k1)) (g '::: ('Nil :: Path k1 k1)) -> Sq ('Nil :: Path j2 j2) ('Nil :: Path k2 k2) (h '::: ('Nil :: Path k2 k2)) (i '::: ('Nil :: Path k2 k2)) -> Sq ('Nil :: Path (j1, j2) (j1, j2)) ('Nil :: Path (k1, k2) (k1, k2)) ((f :**: h) '::: ('Nil :: Path (k1, k2) (k1, k2))) ((g :**: i) '::: ('Nil :: Path (k1, k2) (k1, k2)))
- object :: CategoryOf k => Sq ('Nil :: Path k k) ('Nil :: Path k k) ('Nil :: Path k k) ('Nil :: Path k k)
- vArr :: forall {k} {i} (p :: k +-> i) (q :: k +-> i). (Profunctor p, Profunctor q) => (p :~> q) -> Sq (p '::: ('Nil :: Path i i)) (q '::: ('Nil :: Path i i)) ('Nil :: Path i i) ('Nil :: Path k k)
- vId :: forall {k} {i} (p :: k +-> i). Profunctor p => Sq (p '::: ('Nil :: Path i i)) (p '::: ('Nil :: Path i i)) ('Nil :: Path i i) ('Nil :: Path k k)
- hArr :: forall {j} {k} (f :: j +-> k) (g :: j +-> k). (Representable f, Representable g) => (f :~> g) -> Sq ('Nil :: Path j j) ('Nil :: Path k k) (f '::: ('Nil :: Path k k)) (g '::: ('Nil :: Path k k))
- hId :: forall {j} {k} (f :: j +-> k). Representable f => Sq ('Nil :: Path j j) ('Nil :: Path k k) (f '::: ('Nil :: Path k k)) (f '::: ('Nil :: Path k k))
- hReencode :: forall {j} {k} (fs :: Path j k) (gs :: Path j k). (IsTight fs, IsTight gs, SameRep (Fold fs) (Fold gs)) => Sq ('Nil :: Path j j) ('Nil :: Path k k) fs gs
- (|||) :: forall {b1} {h} {b2} {i} {j} {k} (ps :: Path b1 h) (qs :: Path b2 i) (fs :: Path h i) (gs :: Path b1 b2) (rs :: Path j b1) (ss :: Path k b2) (es :: Path j k). Sq ps qs fs gs -> Sq rs ss gs es -> Sq (rs +++ ps) (ss +++ qs) fs es
- (===) :: forall {a1} {a2} {b1} {b2} {c1} {c2} (ps :: Path a1 a2) (qs :: Path b1 b2) (rs :: Path c1 c2) (ds :: Path a2 b2) (es :: Path a1 b1) (fs :: Path b2 c2) (gs :: Path b1 c1). Sq ps qs ds es -> Sq qs rs fs gs -> Sq ps rs (ds +++ fs) (es +++ gs)
- toBottom :: forall {h} {k} (f :: h +-> k). Representable f => Sq ('Nil :: Path h h) (f '::: ('Nil :: Path k k)) (f '::: ('Nil :: Path k k)) ('Nil :: Path h h)
- toTop :: forall {j} {i} (f :: j +-> i) (f' :: i +-> j). (Proadjunction f f', Representable f) => Sq (f' '::: ('Nil :: Path j j)) ('Nil :: Path i i) (f '::: ('Nil :: Path i i)) ('Nil :: Path i i)
- fromTop :: forall {j} {k} (f :: j +-> k). Representable f => Sq (f '::: ('Nil :: Path k k)) ('Nil :: Path k k) ('Nil :: Path k k) (f '::: ('Nil :: Path k k))
- fromBottom :: forall {j} {k} (f :: j +-> k) (f' :: k +-> j). (Proadjunction f f', Representable f) => Sq ('Nil :: Path j j) (f' '::: ('Nil :: Path j j)) ('Nil :: Path j j) (f '::: ('Nil :: Path k k))
- unitNat :: forall {k1} {j} (p :: k1 +-> j) (q :: j +-> k1). Proadjunction p q => (Id :: k1 -> k1 -> Type) :~> (q :.: p)
- counitNat :: forall {j} {k1} (p :: j +-> k1) (q :: k1 +-> j). Proadjunction p q => (p :.: q) :~> (Id :: k1 -> k1 -> Type)
- hUnitor :: CategoryOf k => Sq ('Nil :: Path k k) ('Nil :: Path k k) ((Id :: k -> k -> Type) '::: ('Nil :: Path k k)) ('Nil :: Path k k)
- hUnitorInv :: CategoryOf k => Sq ('Nil :: Path k k) ('Nil :: Path k k) ('Nil :: Path k k) ((Id :: k -> k -> Type) '::: ('Nil :: Path k k))
- hCombine :: forall {j1} {j2} {k} (f :: j1 +-> j2) (g :: j2 +-> k). (Representable f, Representable g) => Sq ('Nil :: Path j1 j1) ('Nil :: Path k k) (f '::: (g '::: ('Nil :: Path k k))) ((g :.: f) '::: ('Nil :: Path k k))
- hSplit :: forall {j1} {j2} {k} (f :: j1 +-> j2) (g :: j2 +-> k). (Representable f, Representable g) => Sq ('Nil :: Path j1 j1) ('Nil :: Path k k) ((g :.: f) '::: ('Nil :: Path k k)) (f '::: (g '::: ('Nil :: Path k k)))
- hCombineCorep :: forall {j1} {j2} {k} (p :: j1 +-> j2) (q :: k +-> j1). (Corepresentable p, Corepresentable q) => Sq ('Nil :: Path j2 j2) ('Nil :: Path k k) (CorepStar p '::: (CorepStar q '::: ('Nil :: Path k k))) (CorepStar (p :.: q) '::: ('Nil :: Path k k))
- hSplitCorep :: forall {j1} {j2} {k} (p :: j1 +-> j2) (q :: k +-> j1). (Corepresentable p, Corepresentable q) => Sq ('Nil :: Path j2 j2) ('Nil :: Path k k) (CorepStar (p :.: q) '::: ('Nil :: Path k k)) (CorepStar p '::: (CorepStar q '::: ('Nil :: Path k k)))
- hCombineAll :: forall {j} {k} (fs :: Path j k). IsTight fs => Sq ('Nil :: Path j j) ('Nil :: Path k k) fs (Fold fs '::: ('Nil :: Path k k))
- hSplitAll :: forall {h} {i} (fs :: Path h i). IsTight fs => Sq ('Nil :: Path h h) ('Nil :: Path i i) (Fold fs '::: ('Nil :: Path i i)) fs
- vUnitor :: CategoryOf k => Sq ((Id :: k -> k -> Type) '::: ('Nil :: Path k k)) ('Nil :: Path k k) ('Nil :: Path k k) ('Nil :: Path k k)
- vUnitorInv :: CategoryOf k => Sq ('Nil :: Path k k) ((Id :: k -> k -> Type) '::: ('Nil :: Path k k)) ('Nil :: Path k k) ('Nil :: Path k k)
- vCombine :: forall {k} {j} {i} (p :: k +-> j) (q :: j +-> i). (Profunctor p, Profunctor q) => Sq (p '::: (q '::: ('Nil :: Path i i))) ((q :.: p) '::: ('Nil :: Path i i)) ('Nil :: Path i i) ('Nil :: Path k k)
- vSplit :: forall {k} {j} {i} (p :: k +-> j) (q :: j +-> i). (Profunctor p, Profunctor q) => Sq ((q :.: p) '::: ('Nil :: Path i i)) (p '::: (q '::: ('Nil :: Path i i))) ('Nil :: Path i i) ('Nil :: Path k k)
- vCombineAll :: forall {k} {i} (ps :: Path k i). IsPath ps => Sq ps (Fold ps '::: ('Nil :: Path i i)) ('Nil :: Path i i) ('Nil :: Path k k)
- vSplitAll :: forall {k} {i} (ps :: Path k i). IsPath ps => Sq (Fold ps '::: ('Nil :: Path i i)) ps ('Nil :: Path i i) ('Nil :: Path k k)
- unit :: forall {i} {j} (p :: i +-> j) (q :: j +-> i). Proadjunction p q => Sq ('Nil :: Path i i) (p '::: (q '::: ('Nil :: Path i i))) ('Nil :: Path i i) ('Nil :: Path i i)
- counit :: forall {j} {i} (p :: j +-> i) (q :: i +-> j). Proadjunction p q => Sq (q '::: (p '::: ('Nil :: Path i i))) ('Nil :: Path i i) ('Nil :: Path i i) ('Nil :: Path i i)
- type InputSquare (r :: k +-> j) (f :: x +-> j) (g :: x +-> k) = Sq ('Nil :: Path x x) (r '::: ('Nil :: Path j j)) (f '::: ('Nil :: Path j j)) (g '::: ('Nil :: Path k k))
- proSquare :: forall {j} {k} (w :: FLAVOR k j) (r :: k +-> j) (p :: j +-> j) (q :: k +-> k). (Prostrong w r, w p q, Profunctor p, Profunctor q) => Sq (q '::: (r '::: (p '::: ('Nil :: Path j j)))) (r '::: ('Nil :: Path j j)) ('Nil :: Path j j) ('Nil :: Path k k)
- opticSquare :: forall {j} {k} {x} (w :: FLAVOR k j) (r :: k +-> j) (p :: j +-> j) (q :: k +-> k) (s :: x +-> j) (t :: x +-> k) (a :: x +-> j) (b :: x +-> k). (Prostrong w r, w p q, Profunctor p, Profunctor q) => InputSquare p s a -> InputSquare q b t -> InputSquare r a b -> InputSquare r s t
Documentation
data Sq (p :: Path j h) (q :: Path k i) (f :: Path h i) (g :: Path j k) where Source Github #
The kind of a square p q f g.
h---p---j | | | f>--@-->g | | | i---q---k
mapSq :: forall {j1} {h1} {i1} {k1} {j2} {h2} {k2} {i2} (ps :: Path j1 h1) (fs :: Path h1 i1) (gs :: Path j1 k1) (qs :: Path k1 i1) (ps' :: Path j2 h2) (qs' :: Path k2 i2) (fs' :: Path h2 i2) (gs' :: Path j2 k2). (Profunctor (Fold (ps +++ fs)), Profunctor (Fold (gs +++ qs)), IsPath ps', IsPath qs', IsTight fs', IsTight gs') => ((Fold (ps +++ fs) ~> Fold (gs +++ qs)) -> Fold (ps' +++ fs') ~> Fold (gs' +++ qs')) -> Sq ps qs fs gs -> Sq ps' qs' fs' gs' Source Github #
Transform a square's underlying natural transformation through Prof.
All four boundaries may change, as in a universal-property construction.
mkSquare :: forall {j} {h} {k} {i} (ps :: Path j h) (qs :: Path k i) (fs :: Path h i) (gs :: Path j k). (IsPath ps, IsPath qs, IsTight fs, IsTight gs) => (forall (a :: h) (b :: j). (Ob a, Ob b) => Fold ps a b -> Fold qs (Fold fs % a) (Fold gs % b)) -> Sq ps qs fs gs Source Github #
Construct a square from its pointwise action. The representable legs act on the
input objects through %; composition and identity wrappers on those legs are handled
automatically. The action must be natural in both objects.
A traversal crossing, with [] effects and Maybe data:
>>>import Proarrow.Profunctor.Instance.Star (Star, pattern Star, unStar)>>>import Prelude qualified as P>>>type Crossing = Sq (Star [] ::: Nil) (Star [] ::: Nil) (Star P.Maybe ::: Nil) (Star P.Maybe ::: Nil)>>>let crossing = mkSquare (\(Star f) -> Star (P.traverse f)) :: Crossing>>>unStar (runSquare crossing (Star (\x -> [x, P.not x]))) (P.Just P.True)[Just True,Just False]>>>unStar (runSquare crossing (Star (\x -> [x, P.not x]))) P.Nothing[Nothing]
runSquare :: forall {j1} {j2} {k1} {k2} (ps :: Path j1 j2) (qs :: Path k1 k2) (fs :: Path j2 k2) (gs :: Path j1 k1) (a :: j2) (b :: j1). Sq ps qs fs gs -> Fold ps a b -> Fold qs (Fold fs % a) (Fold gs % b) Source Github #
parallel :: forall {j4} {j5} {k4} {k5} {j6} {j7} {k6} {k7} (p :: j4 +-> j5) (q :: k4 +-> k5) (f :: j5 +-> k5) (g :: j4 +-> k4) (p' :: j6 +-> j7) (q' :: k6 +-> k7) (f' :: j7 +-> k7) (g' :: j6 +-> k6). (Profunctor p, Profunctor q, Representable f, Representable g, Profunctor p', Profunctor q', Representable f', Representable g') => Sq (p '::: ('Nil :: Path j5 j5)) (q '::: ('Nil :: Path k5 k5)) (f '::: ('Nil :: Path k5 k5)) (g '::: ('Nil :: Path k4 k4)) -> Sq (p' '::: ('Nil :: Path j7 j7)) (q' '::: ('Nil :: Path k7 k7)) (f' '::: ('Nil :: Path k7 k7)) (g' '::: ('Nil :: Path k6 k6)) -> Sq ((p :**: p') '::: ('Nil :: Path (j5, j7) (j5, j7))) ((q :**: q') '::: ('Nil :: Path (k5, k7) (k5, k7))) ((f :**: f') '::: ('Nil :: Path (k5, k7) (k5, k7))) ((g :**: g') '::: ('Nil :: Path (k4, k6) (k4, k6))) Source Github #
Run two squares with singleton boundaries independently over product categories.
hParallel :: forall {j1} {k1} {j2} {k2} (f :: j1 +-> k1) (g :: j1 +-> k1) (h :: j2 +-> k2) (i :: j2 +-> k2). (Representable f, Representable g, Representable h, Representable i) => Sq ('Nil :: Path j1 j1) ('Nil :: Path k1 k1) (f '::: ('Nil :: Path k1 k1)) (g '::: ('Nil :: Path k1 k1)) -> Sq ('Nil :: Path j2 j2) ('Nil :: Path k2 k2) (h '::: ('Nil :: Path k2 k2)) (i '::: ('Nil :: Path k2 k2)) -> Sq ('Nil :: Path (j1, j2) (j1, j2)) ('Nil :: Path (k1, k2) (k1, k2)) ((f :**: h) '::: ('Nil :: Path (k1, k2) (k1, k2))) ((g :**: i) '::: ('Nil :: Path (k1, k2) (k1, k2))) Source Github #
Run two natural-transformation squares independently, retaining empty loose boundaries.
object :: CategoryOf k => Sq ('Nil :: Path k k) ('Nil :: Path k k) ('Nil :: Path k k) ('Nil :: Path k k) Source Github #
The empty square for an object.
K-------K | | | | | | K-------K
vArr :: forall {k} {i} (p :: k +-> i) (q :: k +-> i). (Profunctor p, Profunctor q) => (p :~> q) -> Sq (p '::: ('Nil :: Path i i)) (q '::: ('Nil :: Path i i)) ('Nil :: Path i i) ('Nil :: Path k k) Source Github #
A square between profunctors, with trivial representable legs.
K---p---J | | | | @ | | | | K---q---J
vId :: forall {k} {i} (p :: k +-> i). Profunctor p => Sq (p '::: ('Nil :: Path i i)) (p '::: ('Nil :: Path i i)) ('Nil :: Path i i) ('Nil :: Path k k) Source Github #
A vertical identity square.
J---p---K | | | | | | | | | J---p---K
hArr :: forall {j} {k} (f :: j +-> k) (g :: j +-> k). (Representable f, Representable g) => (f :~> g) -> Sq ('Nil :: Path j j) ('Nil :: Path k k) (f '::: ('Nil :: Path k k)) (g '::: ('Nil :: Path k k)) Source Github #
A square between representable profunctors, with trivial profunctor legs.
J-------J | | f>--@-->g | | K-------K
hId :: forall {j} {k} (f :: j +-> k). Representable f => Sq ('Nil :: Path j j) ('Nil :: Path k k) (f '::: ('Nil :: Path k k)) (f '::: ('Nil :: Path k k)) Source Github #
A horizontal identity square.
J-------J | | f>----->f | | K-------K
hReencode :: forall {j} {k} (fs :: Path j k) (gs :: Path j k). (IsTight fs, IsTight gs, SameRep (Fold fs) (Fold gs)) => Sq ('Nil :: Path j j) ('Nil :: Path k k) fs gs Source Github #
Re-encode equivalent horizontal functor paths with the same object action. Naturality requires the represented functors to agree on arrows as well. The reverse re-encoding is its inverse, by the representability laws.
(|||) :: forall {b1} {h} {b2} {i} {j} {k} (ps :: Path b1 h) (qs :: Path b2 i) (fs :: Path h i) (gs :: Path b1 b2) (rs :: Path j b1) (ss :: Path k b2) (es :: Path j k). Sq ps qs fs gs -> Sq rs ss gs es -> Sq (rs +++ ps) (ss +++ qs) fs es infixl 6 Source Github #
Horizontal composition, with the left square first. Profunctor paths concatenate from right to left, matching the order of profunctor composition.
H--p--L--r--M H--r+p--M | | | | | f--@--g--@--e = f---@---e | | | | | I--q--J--s--K I--s+q--K
(===) :: forall {a1} {a2} {b1} {b2} {c1} {c2} (ps :: Path a1 a2) (qs :: Path b1 b2) (rs :: Path c1 c2) (ds :: Path a2 b2) (es :: Path a1 b1) (fs :: Path b2 c2) (gs :: Path b1 c1). Sq ps qs ds es -> Sq qs rs fs gs -> Sq ps rs (ds +++ fs) (es +++ gs) infixl 5 Source Github #
Vertical composition, with the top square first.
L---p---M L---p---M | | | | d---@---e | | | | | | H---q---J = d+f--@--e+g | | | | f---@---g | | | | | | I---r---K I---r---K
toBottom :: forall {h} {k} (f :: h +-> k). Representable f => Sq ('Nil :: Path h h) (f '::: ('Nil :: Path k k)) (f '::: ('Nil :: Path k k)) ('Nil :: Path h h) Source Github #
Bend a representable profunctor from the left edge to its companion on the bottom edge.
J-------J | | f>--\ | | v | K---f---J
toTop :: forall {j} {i} (f :: j +-> i) (f' :: i +-> j). (Proadjunction f f', Representable f) => Sq (f' '::: ('Nil :: Path j j)) ('Nil :: Path i i) (f '::: ('Nil :: Path i i)) ('Nil :: Path i i) Source Github #
Bend a representable profunctor from the left edge to its conjoint on the top edge.
J---f---K | ^ | f>--/ | | | K-------K
fromTop :: forall {j} {k} (f :: j +-> k). Representable f => Sq (f '::: ('Nil :: Path k k)) ('Nil :: Path k k) ('Nil :: Path k k) (f '::: ('Nil :: Path k k)) Source Github #
Bend a companion from the top edge back to a representable profunctor on the right edge.
K---f---J | v | | \-->f | | K-------K
fromBottom :: forall {j} {k} (f :: j +-> k) (f' :: k +-> j). (Proadjunction f f', Representable f) => Sq ('Nil :: Path j j) (f' '::: ('Nil :: Path j j)) ('Nil :: Path j j) (f '::: ('Nil :: Path k k)) Source Github #
Bend a conjoint from the bottom edge back to a representable profunctor on the right edge.
J-------J | | | /-->f | ^ | J---f---K
unitNat :: forall {k1} {j} (p :: k1 +-> j) (q :: j +-> k1). Proadjunction p q => (Id :: k1 -> k1 -> Type) :~> (q :.: p) Source Github #
counitNat :: forall {j} {k1} (p :: j +-> k1) (q :: k1 +-> j). Proadjunction p q => (p :.: q) :~> (Id :: k1 -> k1 -> Type) Source Github #
hUnitor :: CategoryOf k => Sq ('Nil :: Path k k) ('Nil :: Path k k) ((Id :: k -> k -> Type) '::: ('Nil :: Path k k)) ('Nil :: Path k k) Source Github #
hUnitorInv :: CategoryOf k => Sq ('Nil :: Path k k) ('Nil :: Path k k) ('Nil :: Path k k) ((Id :: k -> k -> Type) '::: ('Nil :: Path k k)) Source Github #
hCombine :: forall {j1} {j2} {k} (f :: j1 +-> j2) (g :: j2 +-> k). (Representable f, Representable g) => Sq ('Nil :: Path j1 j1) ('Nil :: Path k k) (f '::: (g '::: ('Nil :: Path k k))) ((g :.: f) '::: ('Nil :: Path k k)) Source Github #
hSplit :: forall {j1} {j2} {k} (f :: j1 +-> j2) (g :: j2 +-> k). (Representable f, Representable g) => Sq ('Nil :: Path j1 j1) ('Nil :: Path k k) ((g :.: f) '::: ('Nil :: Path k k)) (f '::: (g '::: ('Nil :: Path k k))) Source Github #
hCombineCorep :: forall {j1} {j2} {k} (p :: j1 +-> j2) (q :: k +-> j1). (Corepresentable p, Corepresentable q) => Sq ('Nil :: Path j2 j2) ('Nil :: Path k k) (CorepStar p '::: (CorepStar q '::: ('Nil :: Path k k))) (CorepStar (p :.: q) '::: ('Nil :: Path k k)) Source Github #
Combine the corepresenting functors of two profunctors into the
corepresenting functor of their composite. CorepStar reverses composition.
hSplitCorep :: forall {j1} {j2} {k} (p :: j1 +-> j2) (q :: k +-> j1). (Corepresentable p, Corepresentable q) => Sq ('Nil :: Path j2 j2) ('Nil :: Path k k) (CorepStar (p :.: q) '::: ('Nil :: Path k k)) (CorepStar p '::: (CorepStar q '::: ('Nil :: Path k k))) Source Github #
Split the corepresenting functor of a composite. Inverse to hCombineCorep.
hCombineAll :: forall {j} {k} (fs :: Path j k). IsTight fs => Sq ('Nil :: Path j j) ('Nil :: Path k k) fs (Fold fs '::: ('Nil :: Path k k)) Source Github #
Combine a path of representable profunctors into one composed representable profunctor.
J---------J f>---\ | | @--->F g>---/ | K---------K
hSplitAll :: forall {h} {i} (fs :: Path h i). IsTight fs => Sq ('Nil :: Path h h) ('Nil :: Path i i) (Fold fs '::: ('Nil :: Path i i)) fs Source Github #
Split one composed representable profunctor into a path of representable profunctors.
J---------J | /--->f F>---@ | | \--->g K---------K
vUnitor :: CategoryOf k => Sq ((Id :: k -> k -> Type) '::: ('Nil :: Path k k)) ('Nil :: Path k k) ('Nil :: Path k k) ('Nil :: Path k k) Source Github #
vUnitorInv :: CategoryOf k => Sq ('Nil :: Path k k) ((Id :: k -> k -> Type) '::: ('Nil :: Path k k)) ('Nil :: Path k k) ('Nil :: Path k k) Source Github #
vCombine :: forall {k} {j} {i} (p :: k +-> j) (q :: j +-> i). (Profunctor p, Profunctor q) => Sq (p '::: (q '::: ('Nil :: Path i i))) ((q :.: p) '::: ('Nil :: Path i i)) ('Nil :: Path i i) ('Nil :: Path k k) Source Github #
vSplit :: forall {k} {j} {i} (p :: k +-> j) (q :: j +-> i). (Profunctor p, Profunctor q) => Sq ((q :.: p) '::: ('Nil :: Path i i)) (p '::: (q '::: ('Nil :: Path i i))) ('Nil :: Path i i) ('Nil :: Path k k) Source Github #
vCombineAll :: forall {k} {i} (ps :: Path k i). IsPath ps => Sq ps (Fold ps '::: ('Nil :: Path i i)) ('Nil :: Path i i) ('Nil :: Path k k) Source Github #
Combine a path of profunctors into one composed profunctor.
K-q---p-J | \ / | | @ | | | | K---F---J
vSplitAll :: forall {k} {i} (ps :: Path k i). IsPath ps => Sq (Fold ps '::: ('Nil :: Path i i)) ps ('Nil :: Path i i) ('Nil :: Path k k) Source Github #
Split one composed profunctor into a path of profunctors.
K---F---J | | | | @ | | / \ | K-q---p-J
unit :: forall {i} {j} (p :: i +-> j) (q :: j +-> i). Proadjunction p q => Sq ('Nil :: Path i i) (p '::: (q '::: ('Nil :: Path i i))) ('Nil :: Path i i) ('Nil :: Path i i) Source Github #
The unit of an adjunction.
J-------J | | | /-@-\ | | | | | J-q---p-J
counit :: forall {j} {i} (p :: j +-> i) (q :: i +-> j). Proadjunction p q => Sq (q '::: (p '::: ('Nil :: Path i i))) ('Nil :: Path i i) ('Nil :: Path i i) ('Nil :: Path i i) Source Github #
The counit of an adjunction.
K-p---q-K | | | | | \-@-/ | | | K-------K
type InputSquare (r :: k +-> j) (f :: x +-> j) (g :: x +-> k) = Sq ('Nil :: Path x x) (r '::: ('Nil :: Path j j)) (f '::: ('Nil :: Path j j)) (g '::: ('Nil :: Path k k)) Source Github #
A square introducing an effect r between representable data shapes f and g,
with no incoming effect. Optics consume and produce squares of this same shape.
X-----------X | | f>----@---->g | | | J-----r-----K
proSquare :: forall {j} {k} (w :: FLAVOR k j) (r :: k +-> j) (p :: j +-> j) (q :: k +-> k). (Prostrong w r, w p q, Profunctor p, Profunctor q) => Sq (q '::: (r '::: (p '::: ('Nil :: Path j j)))) (r '::: ('Nil :: Path j j)) ('Nil :: Path j j) ('Nil :: Path k k) Source Github #
Absorb a general witness pair around an effect with proact. All three incoming
profunctors are vertical or diagonal wires. No representability is required of p or q.
J--p--r--q--K | \ | / | | @@@ | | | | J-----r-----K
opticSquare :: forall {j} {k} {x} (w :: FLAVOR k j) (r :: k +-> j) (p :: j +-> j) (q :: k +-> k) (s :: x +-> j) (t :: x +-> k) (a :: x +-> j) (b :: x +-> k). (Prostrong w r, w p q, Profunctor p, Profunctor q) => InputSquare p s a -> InputSquare q b t -> InputSquare r a b -> InputSquare r s t Source Github #
An optic between representable data shapes, programmed by composing squares.
Its legs s :~> p :.: a and b :~> q :.: t introduce the residual profunctors
p and q, which are absorbed with the input effect by proSquare. All four
data shapes share an index category. Constant shapes from the terminal category
recover optics between individual objects.
Wire names appear on borders; each contiguous run of @ marks one transformation. The top central
square is the input, the left square unpacks, and the right square rebuilds. The
lower square absorbs their three outgoing effects. Residual profunctors stay
vertical or diagonal; only representable data wires run horizontally:
X-----+-----+-----X | | | | s>-@->a>-@->b>-@->t | | | | | | | +--p--+--r--+--q--+ | \ | / | | @@@@@@@@@ | | | | J--------r--------K
The outer boundary is another input-shaped square, now with data legs s and t,
so it can be used as the input to another optic.