{-# LANGUAGE DerivingStrategies #-}

module Proarrow.Profunctor.Ran where

import Prelude (type (~))

import Proarrow.Adjunction (Adjunction (..), counitFromRepCounit, unitFromRepUnit)
import Proarrow.Category.Instance.Nat (Nat (..))
import Proarrow.Category.Instance.Prof (Prof (..))
import Proarrow.Category.Opposite (OPPOSITE (..), Op (..))
import Proarrow.Core (CategoryOf (..), Profunctor (..), Promonad (..), lmap, rmap, (//), type (+->))
import Proarrow.Functor (Functor (..))
import Proarrow.Profunctor.Composition ((:.:) (..))
import Proarrow.Profunctor.Costar (Costar (..))
import Proarrow.Profunctor.Star (Star (..))

-- Note: Ran and Rift are swapped compared to the profunctors package.

type j |> p = Ran (OP j) p

type Ran :: OPPOSITE (i +-> j) -> i +-> k -> j +-> k
data Ran j p a b where
  Ran :: (Ob a, Ob b) => {forall {k} {j} {i} (a :: k) (b :: j) (j :: i +-> j) (p :: i +-> k).
Ran ('OP j) p a b -> forall (x :: i). Ob x => j b x -> p a x
unRan :: forall x. (Ob x) => j b x -> p a x} -> Ran (OP j) p a b

runRan :: (Profunctor j) => j b x -> Ran (OP j) p a b -> p a x
runRan :: forall {j} {i} {k} (j :: PRO j i) (b :: j) (x :: i) (p :: i +-> k)
       (a :: k).
Profunctor j =>
j b x -> Ran ('OP j) p a b -> p a x
runRan j b x
j (Ran forall (x :: i). Ob x => j b x -> p a x
k) = j b x -> p a x
forall (x :: i). Ob x => j b x -> p a x
k j b x
j b x
j ((Ob b, Ob x) => p a x) -> j b x -> p a x
forall (a :: j) (b :: i) r. ((Ob a, Ob b) => r) -> j a b -> r
forall {j} {k} (p :: PRO j k) (a :: j) (b :: k) r.
Profunctor p =>
((Ob a, Ob b) => r) -> p a b -> r
\\ j b x
j

flipRan :: (Functor j, Profunctor p) => Costar j |> p ~> p :.: Star j
flipRan :: forall {i} {k2} {k} (j :: i -> k2) (p :: PRO k k2).
(Functor j, Profunctor p) =>
(Costar j |> p) ~> (p :.: Star j)
flipRan = ((Costar j |> p) :~> (p :.: Star j))
-> Prof (Costar j |> p) (p :.: Star j)
forall {k} {j} (p :: j +-> k) (q :: j +-> k).
(Profunctor p, Profunctor q) =>
(p :~> q) -> Prof p q
Prof \(Ran forall (x :: k2). Ob x => j b x -> p a x
k) -> j b (j b) -> p a (j b)
forall (x :: k2). Ob x => j b x -> p a x
k ((j b ~> j b) -> Costar j b (j b)
forall {j} {k} (a :: j) (f :: j -> k) (b :: k).
Ob a =>
(f a ~> b) -> Costar f a b
Costar j b ~> j b
forall (a :: k2). Ob a => a ~> a
forall {k} (p :: PRO k k) (a :: k). (Promonad p, Ob a) => p a a
id) p a (j b) -> Star j (j b) b -> (:.:) p (Star j) a b
forall {j} {k} {i} (p :: j +-> k) (a :: k) (b :: j) (q :: i +-> j)
       (c :: i).
p a b -> q b c -> (:.:) p q a c
:.: (j b ~> j b) -> Star j (j b) b
forall {k1} {k2} (b :: k1) (a :: k2) (f :: k1 -> k2).
Ob b =>
(a ~> f b) -> Star f a b
Star j b ~> j b
forall (a :: k2). Ob a => a ~> a
forall {k} (p :: PRO k k) (a :: k). (Promonad p, Ob a) => p a a
id

flipRanInv :: (Functor j, Profunctor p) => p :.: Star j ~> Costar j |> p
flipRanInv :: forall {j} {i} {k} (j :: j -> i) (p :: PRO k i).
(Functor j, Profunctor p) =>
(p :.: Star j) ~> (Costar j |> p)
flipRanInv = ((p :.: Star j) :~> (Costar j |> p))
-> Prof (p :.: Star j) (Costar j |> p)
forall {k} {j} (p :: j +-> k) (q :: j +-> k).
(Profunctor p, Profunctor q) =>
(p :~> q) -> Prof p q
Prof \(p a b
p :.: Star b ~> j b
f) -> p a b
p p a b
-> ((Ob a, Ob b) => (|>) (Costar j) p a b) -> (|>) (Costar j) p a b
forall {k1} {k2} (p :: PRO k1 k2) (a :: k1) (b :: k2) r.
Profunctor p =>
p a b -> ((Ob a, Ob b) => r) -> r
// (forall (x :: i). Ob x => Costar j b x -> p a x)
-> (|>) (Costar j) p a b
forall {k} {j} {i} (a :: k) (b :: j) (j :: i +-> j) (p :: i +-> k).
(Ob a, Ob b) =>
(forall (x :: i). Ob x => j b x -> p a x) -> Ran ('OP j) p a b
Ran \(Costar j b ~> x
g) -> (b ~> x) -> p a b -> p a x
forall {j} {k} (p :: PRO j k) (b :: k) (d :: k) (a :: j).
Profunctor p =>
(b ~> d) -> p a b -> p a d
rmap (j b ~> x
g (j b ~> x) -> (b ~> j b) -> b ~> x
forall (b :: i) (c :: i) (a :: i). (b ~> c) -> (a ~> b) -> a ~> c
forall {k} (p :: PRO k k) (b :: k) (c :: k) (a :: k).
Promonad p =>
p b c -> p a b -> p a c
. b ~> j b
f) p a b
p

instance (Profunctor p, Profunctor j) => Profunctor (Ran (OP j) p) where
  dimap :: forall (c :: j) (a :: j) (b :: k) (d :: k).
(c ~> a) -> (b ~> d) -> Ran ('OP j) p a b -> Ran ('OP j) p c d
dimap c ~> a
l b ~> d
r (Ran forall (x :: i). Ob x => j b x -> p a x
k) = c ~> a
l (c ~> a)
-> ((Ob c, Ob a) => Ran ('OP j) p c d) -> Ran ('OP j) p c d
forall {k1} {k2} (p :: PRO k1 k2) (a :: k1) (b :: k2) r.
Profunctor p =>
p a b -> ((Ob a, Ob b) => r) -> r
// b ~> d
r (b ~> d)
-> ((Ob b, Ob d) => Ran ('OP j) p c d) -> Ran ('OP j) p c d
forall {k1} {k2} (p :: PRO k1 k2) (a :: k1) (b :: k2) r.
Profunctor p =>
p a b -> ((Ob a, Ob b) => r) -> r
// (forall (x :: i). Ob x => j d x -> p c x) -> Ran ('OP j) p c d
forall {k} {j} {i} (a :: k) (b :: j) (j :: i +-> j) (p :: i +-> k).
(Ob a, Ob b) =>
(forall (x :: i). Ob x => j b x -> p a x) -> Ran ('OP j) p a b
Ran ((c ~> a) -> p a x -> p c x
forall {j} {k} (p :: PRO j k) (c :: j) (a :: j) (b :: k).
Profunctor p =>
(c ~> a) -> p a b -> p c b
lmap c ~> a
l (p a x -> p c x) -> (j d x -> p a x) -> j d x -> p c x
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (p :: PRO k k) (b :: k) (c :: k) (a :: k).
Promonad p =>
p b c -> p a b -> p a c
. j b x -> p a x
j b x -> p a x
forall (x :: i). Ob x => j b x -> p a x
k (j b x -> p a x) -> (j d x -> j b x) -> j d x -> p a x
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (p :: PRO k k) (b :: k) (c :: k) (a :: k).
Promonad p =>
p b c -> p a b -> p a c
. (b ~> d) -> j d x -> j b x
forall {j} {k} (p :: PRO j k) (c :: j) (a :: j) (b :: k).
Profunctor p =>
(c ~> a) -> p a b -> p c b
lmap b ~> d
r)
  (Ob a, Ob b) => r
r \\ :: forall (a :: j) (b :: k) r.
((Ob a, Ob b) => r) -> Ran ('OP j) p a b -> r
\\ Ran{} = r
(Ob a, Ob b) => r
r

instance (Profunctor j) => Functor (Ran (OP j)) where
  map :: forall (a :: i +-> k) (b :: i +-> k).
(a ~> b) -> Ran ('OP j) a ~> Ran ('OP j) b
map (Prof a :~> b
n) = (Ran ('OP j) a :~> Ran ('OP j) b)
-> Prof (Ran ('OP j) a) (Ran ('OP j) b)
forall {k} {j} (p :: j +-> k) (q :: j +-> k).
(Profunctor p, Profunctor q) =>
(p :~> q) -> Prof p q
Prof \(Ran forall (x :: i). Ob x => j b x -> a a x
k) -> (forall (x :: i). Ob x => j b x -> b a x) -> Ran ('OP j) b a b
forall {k} {j} {i} (a :: k) (b :: j) (j :: i +-> j) (p :: i +-> k).
(Ob a, Ob b) =>
(forall (x :: i). Ob x => j b x -> p a x) -> Ran ('OP j) p a b
Ran (a a x -> b a x
a :~> b
n (a a x -> b a x) -> (j b x -> a a x) -> j b x -> b a x
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (p :: PRO k k) (b :: k) (c :: k) (a :: k).
Promonad p =>
p b c -> p a b -> p a c
. j b x -> a a x
j b x -> a a x
forall (x :: i). Ob x => j b x -> a a x
k)

instance Functor Ran where
  map :: forall (a :: OPPOSITE (i +-> j)) (b :: OPPOSITE (i +-> j)).
(a ~> b) -> Ran a ~> Ran b
map (Op (Prof b1 :~> a1
n)) = (Ran ('OP a1) .~> Ran ('OP b1))
-> Nat (Ran ('OP a1)) (Ran ('OP b1))
forall {j} {k} (f :: j -> k) (g :: j -> k).
(Functor f, Functor g) =>
(f .~> g) -> Nat f g
Nat ((Ran ('OP a1) a :~> Ran ('OP b1) a)
-> Prof (Ran ('OP a1) a) (Ran ('OP b1) a)
forall {k} {j} (p :: j +-> k) (q :: j +-> k).
(Profunctor p, Profunctor q) =>
(p :~> q) -> Prof p q
Prof \(Ran forall (x :: i). Ob x => j b x -> a a x
k) -> (forall (x :: i). Ob x => b1 b x -> a a x) -> Ran ('OP b1) a a b
forall {k} {j} {i} (a :: k) (b :: j) (j :: i +-> j) (p :: i +-> k).
(Ob a, Ob b) =>
(forall (x :: i). Ob x => j b x -> p a x) -> Ran ('OP j) p a b
Ran (a1 b x -> a a x
j b x -> a a x
forall (x :: i). Ob x => j b x -> a a x
k (a1 b x -> a a x) -> (b1 b x -> a1 b x) -> b1 b x -> a a x
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (p :: PRO k k) (b :: k) (c :: k) (a :: k).
Promonad p =>
p b c -> p a b -> p a c
. b1 b x -> a1 b x
b1 :~> a1
n))

instance (p ~ j, Profunctor p) => Promonad (Ran (OP p) p) where
  id :: forall (a :: k). Ob a => Ran ('OP p) p a a
id = (forall (x :: i). Ob x => p a x -> p a x) -> Ran ('OP p) p a a
forall {k} {j} {i} (a :: k) (b :: j) (j :: i +-> j) (p :: i +-> k).
(Ob a, Ob b) =>
(forall (x :: i). Ob x => j b x -> p a x) -> Ran ('OP j) p a b
Ran p a x -> p a x
j a x -> j a x
forall (x :: i). Ob x => p a x -> p a x
forall a. Ob a => a -> a
forall {k} (p :: PRO k k) (a :: k). (Promonad p, Ob a) => p a a
id
  Ran forall (x :: i). Ob x => j c x -> p b x
l . :: forall (b :: k) (c :: k) (a :: k).
Ran ('OP p) p b c -> Ran ('OP p) p a b -> Ran ('OP p) p a c
. Ran forall (x :: i). Ob x => j b x -> p a x
r = (forall (x :: i). Ob x => p c x -> p a x) -> Ran ('OP p) p a c
forall {k} {j} {i} (a :: k) (b :: j) (j :: i +-> j) (p :: i +-> k).
(Ob a, Ob b) =>
(forall (x :: i). Ob x => j b x -> p a x) -> Ran ('OP j) p a b
Ran (j b x -> j a x
j b x -> p a x
forall (x :: i). Ob x => j b x -> p a x
r (j b x -> j a x) -> (j c x -> j b x) -> j c x -> j a x
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (p :: PRO k k) (b :: k) (c :: k) (a :: k).
Promonad p =>
p b c -> p a b -> p a c
. j c x -> j b x
j c x -> p b x
forall (x :: i). Ob x => j c x -> p b x
l)

newtype Precompose j p a b = Precompose {forall {i} {j} {k} (j :: i +-> j) (p :: j +-> k) (a :: k) (b :: i).
Precompose j p a b -> (:.:) p j a b
unPrecompose :: (p :.: j) a b}
instance (Profunctor j, Profunctor p) => Profunctor (Precompose j p) where
  dimap :: forall (c :: j) (a :: j) (b :: k) (d :: k).
(c ~> a) -> (b ~> d) -> Precompose j p a b -> Precompose j p c d
dimap c ~> a
l b ~> d
r (Precompose (:.:) p j a b
pj) = (:.:) p j c d -> Precompose j p c d
forall {i} {j} {k} (j :: i +-> j) (p :: j +-> k) (a :: k) (b :: i).
(:.:) p j a b -> Precompose j p a b
Precompose ((c ~> a) -> (b ~> d) -> (:.:) p j a b -> (:.:) p j c d
forall (c :: j) (a :: j) (b :: k) (d :: k).
(c ~> a) -> (b ~> d) -> (:.:) p j a b -> (:.:) p j c d
forall {j} {k} (p :: PRO j k) (c :: j) (a :: j) (b :: k) (d :: k).
Profunctor p =>
(c ~> a) -> (b ~> d) -> p a b -> p c d
dimap c ~> a
l b ~> d
r (:.:) p j a b
pj)
  (Ob a, Ob b) => r
r \\ :: forall (a :: j) (b :: k) r.
((Ob a, Ob b) => r) -> Precompose j p a b -> r
\\ Precompose (:.:) p j a b
pj = r
(Ob a, Ob b) => r
r ((Ob a, Ob b) => r) -> (:.:) p j a b -> r
forall (a :: j) (b :: k) r.
((Ob a, Ob b) => r) -> (:.:) p j a b -> r
forall {j} {k} (p :: PRO j k) (a :: j) (b :: k) r.
Profunctor p =>
((Ob a, Ob b) => r) -> p a b -> r
\\ (:.:) p j a b
pj
instance (Profunctor j) => Functor (Precompose j) where
  map :: forall (a :: j +-> k) (b :: j +-> k).
(a ~> b) -> Precompose j a ~> Precompose j b
map a ~> b
f = a ~> b
Prof a b
f Prof a b
-> ((Ob a, Ob b) => Prof (Precompose j a) (Precompose j b))
-> Prof (Precompose j a) (Precompose j b)
forall {k1} {k2} (p :: PRO k1 k2) (a :: k1) (b :: k2) r.
Profunctor p =>
p a b -> ((Ob a, Ob b) => r) -> r
// (Precompose j a :~> Precompose j b)
-> Prof (Precompose j a) (Precompose j b)
forall {k} {j} (p :: j +-> k) (q :: j +-> k).
(Profunctor p, Profunctor q) =>
(p :~> q) -> Prof p q
Prof \(Precompose (:.:) a j a b
pj) -> (:.:) b j a b -> Precompose j b a b
forall {i} {j} {k} (j :: i +-> j) (p :: j +-> k) (a :: k) (b :: i).
(:.:) p j a b -> Precompose j p a b
Precompose (Prof (a :.: j) (b :.: j) -> (a :.: j) :~> (b :.: j)
forall {k} {k1} (p :: PRO k k1) (q :: PRO k k1).
Prof p q -> p :~> q
unProf (Nat ((:.:) a) ((:.:) b) -> (:.:) a .~> (:.:) b
forall {k} {k1} (f :: k -> k1) (g :: k -> k1). Nat f g -> f .~> g
unNat ((a ~> b) -> (:.:) a ~> (:.:) b
forall {k1} {k2} (f :: k1 -> k2) (a :: k1) (b :: k1).
Functor f =>
(a ~> b) -> f a ~> f b
forall (a :: j +-> k) (b :: j +-> k).
(a ~> b) -> (:.:) a ~> (:.:) b
map a ~> b
f)) (:.:) a j a b
pj)

instance (Profunctor j) => Adjunction (Star (Precompose j)) (Star (Ran (OP j))) where
  unit :: forall (a :: j +-> k).
Ob a =>
(:.:) (Star (Ran ('OP j))) (Star (Precompose j)) a a
unit = (a ~> (Star (Ran ('OP j)) % (Star (Precompose j) % a)))
-> (:.:) (Star (Ran ('OP j))) (Star (Precompose j)) a a
forall {i} {j} (l :: i +-> j) (r :: j +-> i) (a :: i).
(Representable l, Representable r, Ob a) =>
(a ~> (r % (l % a))) -> (:.:) r l a a
unitFromRepUnit ((a :~> Ran ('OP j) (Precompose j a))
-> Prof a (Ran ('OP j) (Precompose j a))
forall {k} {j} (p :: j +-> k) (q :: j +-> k).
(Profunctor p, Profunctor q) =>
(p :~> q) -> Prof p q
Prof \a a b
p -> a a b
p a a b
-> ((Ob a, Ob b) => Ran ('OP j) (Precompose j a) a b)
-> Ran ('OP j) (Precompose j a) a b
forall {k1} {k2} (p :: PRO k1 k2) (a :: k1) (b :: k2) r.
Profunctor p =>
p a b -> ((Ob a, Ob b) => r) -> r
// (forall (x :: i). Ob x => j b x -> Precompose j a a x)
-> Ran ('OP j) (Precompose j a) a b
forall {k} {j} {i} (a :: k) (b :: j) (j :: i +-> j) (p :: i +-> k).
(Ob a, Ob b) =>
(forall (x :: i). Ob x => j b x -> p a x) -> Ran ('OP j) p a b
Ran \j b x
j -> (:.:) a j a x -> Precompose j a a x
forall {i} {j} {k} (j :: i +-> j) (p :: j +-> k) (a :: k) (b :: i).
(:.:) p j a b -> Precompose j p a b
Precompose (a a b
p a a b -> j b x -> (:.:) a j a x
forall {j} {k} {i} (p :: j +-> k) (a :: k) (b :: j) (q :: i +-> j)
       (c :: i).
p a b -> q b c -> (:.:) p q a c
:.: j b x
j))
  counit :: (Star (Precompose j) :.: Star (Ran ('OP j))) :~> (~>)
counit = (forall (c :: k -> i -> Type).
 Ob c =>
 (Star (Precompose j) % (Star (Ran ('OP j)) % c)) ~> c)
-> (Star (Precompose j) :.: Star (Ran ('OP j))) :~> (~>)
forall {j} {k1} (l :: j +-> k1) (r :: k1 +-> j).
(Representable l, Representable r) =>
(forall (c :: k1). Ob c => (l % (r % c)) ~> c)
-> (l :.: r) :~> (~>)
counitFromRepCounit ((Precompose j (Ran ('OP j) c) :~> c)
-> Prof (Precompose j (Ran ('OP j) c)) c
forall {k} {j} (p :: j +-> k) (q :: j +-> k).
(Profunctor p, Profunctor q) =>
(p :~> q) -> Prof p q
Prof \(Precompose (Ran ('OP j) c a b
r :.: j b b
j)) -> j b b -> Ran ('OP j) c a b -> c a b
forall {j} {i} {k} (j :: PRO j i) (b :: j) (x :: i) (p :: i +-> k)
       (a :: k).
Profunctor j =>
j b x -> Ran ('OP j) p a b -> p a x
runRan j b b
j Ran ('OP j) c a b
r)

ranCompose :: (Profunctor i, Profunctor j, Profunctor p) => i |> (j |> p) ~> (i :.: j) |> p
ranCompose :: forall {j} {j} {i} {k} (i :: PRO j j) (j :: PRO j i)
       (p :: PRO k i).
(Profunctor i, Profunctor j, Profunctor p) =>
(i |> (j |> p)) ~> ((i :.: j) |> p)
ranCompose = ((i |> (j |> p)) :~> ((i :.: j) |> p))
-> Prof (i |> (j |> p)) ((i :.: j) |> p)
forall {k} {j} (p :: j +-> k) (q :: j +-> k).
(Profunctor p, Profunctor q) =>
(p :~> q) -> Prof p q
Prof \(|>) i (j |> p) a b
k -> (|>) i (j |> p) a b
k (|>) i (j |> p) a b
-> ((Ob a, Ob b) => (|>) (i :.: j) p a b) -> (|>) (i :.: j) p a b
forall {k1} {k2} (p :: PRO k1 k2) (a :: k1) (b :: k2) r.
Profunctor p =>
p a b -> ((Ob a, Ob b) => r) -> r
// (forall (x :: i). Ob x => (:.:) i j b x -> p a x)
-> (|>) (i :.: j) p a b
forall {k} {j} {i} (a :: k) (b :: j) (j :: i +-> j) (p :: i +-> k).
(Ob a, Ob b) =>
(forall (x :: i). Ob x => j b x -> p a x) -> Ran ('OP j) p a b
Ran \(i b b
i :.: j b x
j) -> j b x -> Ran ('OP j) p a b -> p a x
forall {j} {i} {k} (j :: PRO j i) (b :: j) (x :: i) (p :: i +-> k)
       (a :: k).
Profunctor j =>
j b x -> Ran ('OP j) p a b -> p a x
runRan j b x
j (i b b -> (|>) i (j |> p) a b -> Ran ('OP j) p a b
forall {j} {i} {k} (j :: PRO j i) (b :: j) (x :: i) (p :: i +-> k)
       (a :: k).
Profunctor j =>
j b x -> Ran ('OP j) p a b -> p a x
runRan i b b
i (|>) i (j |> p) a b
k)

ranComposeInv :: (Profunctor i, Profunctor j, Profunctor p) => (i :.: j) |> p ~> i |> (j |> p)
ranComposeInv :: forall {j} {j} {i} {k} (i :: PRO j j) (j :: PRO j i)
       (p :: PRO k i).
(Profunctor i, Profunctor j, Profunctor p) =>
((i :.: j) |> p) ~> (i |> (j |> p))
ranComposeInv = (((i :.: j) |> p) :~> (i |> (j |> p)))
-> Prof ((i :.: j) |> p) (i |> (j |> p))
forall {k} {j} (p :: j +-> k) (q :: j +-> k).
(Profunctor p, Profunctor q) =>
(p :~> q) -> Prof p q
Prof \(|>) (i :.: j) p a b
k -> (|>) (i :.: j) p a b
k (|>) (i :.: j) p a b
-> ((Ob a, Ob b) => (|>) i (j |> p) a b) -> (|>) i (j |> p) a b
forall {k1} {k2} (p :: PRO k1 k2) (a :: k1) (b :: k2) r.
Profunctor p =>
p a b -> ((Ob a, Ob b) => r) -> r
// (forall (x :: j). Ob x => i b x -> (|>) j p a x)
-> (|>) i (j |> p) a b
forall {k} {j} {i} (a :: k) (b :: j) (j :: i +-> j) (p :: i +-> k).
(Ob a, Ob b) =>
(forall (x :: i). Ob x => j b x -> p a x) -> Ran ('OP j) p a b
Ran \i b x
i -> (forall (x :: i). Ob x => j x x -> p a x) -> (|>) j p a x
forall {k} {j} {i} (a :: k) (b :: j) (j :: i +-> j) (p :: i +-> k).
(Ob a, Ob b) =>
(forall (x :: i). Ob x => j b x -> p a x) -> Ran ('OP j) p a b
Ran \j x x
j -> (:.:) i j b x -> (|>) (i :.: j) p a b -> p a x
forall {j} {i} {k} (j :: PRO j i) (b :: j) (x :: i) (p :: i +-> k)
       (a :: k).
Profunctor j =>
j b x -> Ran ('OP j) p a b -> p a x
runRan (i b x
i i b x -> j x x -> (:.:) i j b x
forall {j} {k} {i} (p :: j +-> k) (a :: k) (b :: j) (q :: i +-> j)
       (c :: i).
p a b -> q b c -> (:.:) p q a c
:.: j x x
j) (|>) (i :.: j) p a b
k

ranHom :: Profunctor p => p ~> (~>) |> p
ranHom :: forall {k} {i} (p :: PRO k i). Profunctor p => p ~> ((~>) |> p)
ranHom = (p :~> ((~>) |> p)) -> Prof p ((~>) |> p)
forall {k} {j} (p :: j +-> k) (q :: j +-> k).
(Profunctor p, Profunctor q) =>
(p :~> q) -> Prof p q
Prof \p a b
p -> p a b
p p a b -> ((Ob a, Ob b) => (|>) (~>) p a b) -> (|>) (~>) p a b
forall {k1} {k2} (p :: PRO k1 k2) (a :: k1) (b :: k2) r.
Profunctor p =>
p a b -> ((Ob a, Ob b) => r) -> r
// (forall (x :: i). Ob x => (b ~> x) -> p a x) -> (|>) (~>) p a b
forall {k} {j} {i} (a :: k) (b :: j) (j :: i +-> j) (p :: i +-> k).
(Ob a, Ob b) =>
(forall (x :: i). Ob x => j b x -> p a x) -> Ran ('OP j) p a b
Ran \b ~> x
j -> (b ~> x) -> p a b -> p a x
forall {j} {k} (p :: PRO j k) (b :: k) (d :: k) (a :: j).
Profunctor p =>
(b ~> d) -> p a b -> p a d
rmap b ~> x
j p a b
p

ranHomInv :: Profunctor p => (~>) |> p ~> p
ranHomInv :: forall {k} {i} (p :: PRO k i). Profunctor p => ((~>) |> p) ~> p
ranHomInv = (((~>) |> p) :~> p) -> Prof ((~>) |> p) p
forall {k} {j} (p :: j +-> k) (q :: j +-> k).
(Profunctor p, Profunctor q) =>
(p :~> q) -> Prof p q
Prof \(Ran forall (x :: i). Ob x => j b x -> p a x
k) -> j b b -> p a b
forall (x :: i). Ob x => j b x -> p a x
k j b b
forall (a :: i). Ob a => j a a
forall {k} (p :: PRO k k) (a :: k). (Promonad p, Ob a) => p a a
id