{-# LANGUAGE AllowAmbiguousTypes #-}

module Proarrow.Category.Instance.Simplex where

import Data.Kind (Type)

import Prelude (type (~))

import Proarrow.Category.Monoidal (Monoidal (..), MonoidalProfunctor (..))
import Proarrow.Core (CAT, CategoryOf (..), Profunctor (..), Promonad (..), dimapDefault, obj, src, type (+->))
import Proarrow.Monoid (Monoid (..))
import Proarrow.Object.Initial (HasInitialObject (..))
import Proarrow.Object.Terminal (HasTerminalObject (..))
import Proarrow.Profunctor.Representable (Representable (..), dimapRep)

type data Nat = Z | S Nat
data SNat :: Nat -> Type where
  SZ :: SNat Z
  SS :: (IsNat n) => SNat (S n)

class ((a + b) + c ~ a + (b + c)) => Assoc a b c
instance ((a + b) + c ~ a + (b + c)) => Assoc a b c

class (a + Z ~ a, forall b c. Assoc a b c) => IsNat (a :: Nat) where singNat :: SNat a
instance IsNat Z where singNat :: SNat Z
singNat = SNat Z
SZ
instance (IsNat a) => IsNat (S a) where singNat :: SNat (S a)
singNat = SNat (S a)
forall (a :: Nat). IsNat a => SNat (S a)
SS

type Simplex :: CAT Nat
data Simplex a b where
  ZZ :: Simplex Z Z
  Y :: Simplex x y -> Simplex x (S y)
  X :: Simplex x (S y) -> Simplex (S x) (S y)

suc :: Simplex a b -> Simplex (S a) (S b)
suc :: forall (a :: Nat) (b :: Nat). Simplex a b -> Simplex (S a) (S b)
suc = Simplex a (S b) -> Simplex (S a) (S b)
forall (n :: Nat) (y :: Nat).
Simplex n (S y) -> Simplex (S n) (S y)
X (Simplex a (S b) -> Simplex (S a) (S b))
-> (Simplex a b -> Simplex a (S b))
-> Simplex a b
-> Simplex (S a) (S b)
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
. Simplex a b -> Simplex a (S b)
forall (x :: Nat) (n :: Nat). Simplex x n -> Simplex x (S n)
Y

instance CategoryOf Nat where
  type (~>) = Simplex
  type Ob a = IsNat a

instance Promonad Simplex where
  id :: forall (a :: Nat). Ob a => Simplex a a
id @a = case forall (a :: Nat). IsNat a => SNat a
singNat @a of
    SNat a
SZ -> Simplex a a
Simplex Z Z
ZZ
    SNat a
SS -> Simplex n n -> Simplex (S n) (S n)
forall (a :: Nat) (b :: Nat). Simplex a b -> Simplex (S a) (S b)
suc Simplex n n
forall {k} (p :: PRO k k) (a :: k). (Promonad p, Ob a) => p a a
forall (a :: Nat). Ob a => Simplex a a
id
  Simplex b c
ZZ . :: forall (b :: Nat) (c :: Nat) (a :: Nat).
Simplex b c -> Simplex a b -> Simplex a c
. Simplex a b
f = Simplex a b
Simplex a c
f
  Y Simplex b y
f . Simplex a b
g = Simplex a y -> Simplex a (S y)
forall (x :: Nat) (n :: Nat). Simplex x n -> Simplex x (S n)
Y (Simplex b y
f Simplex b y -> Simplex a b -> Simplex a y
forall {k} (p :: PRO k k) (b :: k) (c :: k) (a :: k).
Promonad p =>
p b c -> p a b -> p a c
forall (b :: Nat) (c :: Nat) (a :: Nat).
Simplex b c -> Simplex a b -> Simplex a c
. Simplex a b
g)
  X Simplex x (S y)
f . Y Simplex a y
g = Simplex x c
Simplex x (S y)
f Simplex x c -> Simplex a x -> Simplex 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
forall (b :: Nat) (c :: Nat) (a :: Nat).
Simplex b c -> Simplex a b -> Simplex a c
. Simplex a x
Simplex a y
g
  X Simplex x (S y)
f . X Simplex x (S y)
g = Simplex x (S y) -> Simplex (S x) (S y)
forall (n :: Nat) (y :: Nat).
Simplex n (S y) -> Simplex (S n) (S y)
X (Simplex x (S y) -> Simplex (S x) (S y)
forall (n :: Nat) (y :: Nat).
Simplex n (S y) -> Simplex (S n) (S y)
X Simplex x (S y)
f Simplex (S x) (S y) -> Simplex x (S x) -> Simplex x (S y)
forall {k} (p :: PRO k k) (b :: k) (c :: k) (a :: k).
Promonad p =>
p b c -> p a b -> p a c
forall (b :: Nat) (c :: Nat) (a :: Nat).
Simplex b c -> Simplex a b -> Simplex a c
. Simplex x (S x)
Simplex x (S y)
g)

instance Profunctor Simplex where
  dimap :: forall (c :: Nat) (a :: Nat) (b :: Nat) (d :: Nat).
(c ~> a) -> (b ~> d) -> Simplex a b -> Simplex c d
dimap = (c ~> a) -> (b ~> d) -> Simplex a b -> Simplex c d
Simplex c a -> Simplex b d -> Simplex a b -> Simplex c d
forall {k} (p :: PRO k k) (c :: k) (a :: k) (b :: k) (d :: k).
Promonad p =>
p c a -> p b d -> p a b -> p c d
dimapDefault
  (Ob a, Ob b) => r
r \\ :: forall (a :: Nat) (b :: Nat) r.
((Ob a, Ob b) => r) -> Simplex a b -> r
\\ Simplex a b
ZZ = r
(Ob a, Ob b) => r
r
  (Ob a, Ob b) => r
r \\ Y Simplex a y
f = r
(Ob a, Ob b) => r
(Ob a, Ob y) => r
r ((Ob a, Ob y) => r) -> Simplex a y -> r
forall {j} {k} (p :: PRO j k) (a :: j) (b :: k) r.
Profunctor p =>
((Ob a, Ob b) => r) -> p a b -> r
forall (a :: Nat) (b :: Nat) r.
((Ob a, Ob b) => r) -> Simplex a b -> r
\\ Simplex a y
f
  (Ob a, Ob b) => r
r \\ X Simplex x (S y)
f = r
(Ob a, Ob b) => r
(Ob x, Ob (S y)) => r
r ((Ob x, Ob (S y)) => r) -> Simplex x (S y) -> r
forall {j} {k} (p :: PRO j k) (a :: j) (b :: k) r.
Profunctor p =>
((Ob a, Ob b) => r) -> p a b -> r
forall (a :: Nat) (b :: Nat) r.
((Ob a, Ob b) => r) -> Simplex a b -> r
\\ Simplex x (S y)
f

instance HasInitialObject Nat where
  type InitialObject = Z
  initiate :: forall (a :: Nat). Ob a => InitialObject ~> a
initiate @a = case forall (a :: Nat). IsNat a => SNat a
singNat @a of
    SNat a
SZ -> InitialObject ~> a
Simplex Z Z
ZZ
    SS @a' -> Simplex Z n -> Simplex Z (S n)
forall (x :: Nat) (n :: Nat). Simplex x n -> Simplex x (S n)
Y (forall k (a :: k). (HasInitialObject k, Ob a) => InitialObject ~> a
initiate @_ @a')

instance HasTerminalObject Nat where
  type TerminalObject = S Z
  terminate :: forall (a :: Nat). Ob a => a ~> TerminalObject
terminate @a = case forall (a :: Nat). IsNat a => SNat a
singNat @a of
    SNat a
SZ -> Simplex Z Z -> Simplex Z (S Z)
forall (x :: Nat) (n :: Nat). Simplex x n -> Simplex x (S n)
Y Simplex Z Z
ZZ
    SS @n -> Simplex n (S Z) -> Simplex (S n) (S Z)
forall (n :: Nat) (y :: Nat).
Simplex n (S y) -> Simplex (S n) (S y)
X (forall k (a :: k).
(HasTerminalObject k, Ob a) =>
a ~> TerminalObject
terminate @_ @n)

data Fin :: Nat -> Type where
  Fz :: Fin (S n)
  Fs :: Fin n -> Fin (S n)

type Forget :: Nat +-> Type
data Forget a b where
  Forget :: (Ob b) => {forall (b :: Nat) a. Forget a b -> a -> Fin b
unForget :: a -> Fin b} -> Forget a b

instance Profunctor Forget where
  dimap :: forall c a (b :: Nat) (d :: Nat).
(c ~> a) -> (b ~> d) -> Forget a b -> Forget c d
dimap = (c ~> a) -> (b ~> d) -> Forget a b -> Forget c d
forall {j} {k} (p :: j +-> k) (a :: k) (b :: j) (c :: k) (d :: j).
Representable p =>
(c ~> a) -> (b ~> d) -> p a b -> p c d
dimapRep
  (Ob a, Ob b) => r
r \\ :: forall a (b :: Nat) r. ((Ob a, Ob b) => r) -> Forget a b -> r
\\ Forget a -> Fin b
f = r
(Ob a, Ob (Fin b)) => r
(Ob a, Ob b) => r
r ((Ob a, Ob (Fin b)) => r) -> (a -> Fin b) -> r
forall a b r. ((Ob a, Ob b) => r) -> (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
\\ a -> Fin b
f
instance Representable Forget where
  type Forget % n = Fin n
  index :: forall a (b :: Nat). Forget a b -> a ~> (Forget % b)
index = Forget a b -> a ~> (Forget % b)
Forget a b -> a -> Fin b
forall (b :: Nat) a. Forget a b -> a -> Fin b
unForget
  tabulate :: forall (b :: Nat) a. Ob b => (a ~> (Forget % b)) -> Forget a b
tabulate = (a ~> (Forget % b)) -> Forget a b
(a -> Fin b) -> Forget a b
forall (b :: Nat) a. Ob b => (a -> Fin b) -> Forget a b
Forget
  repMap :: forall (a :: Nat) (b :: Nat).
(a ~> b) -> (Forget % a) ~> (Forget % b)
repMap a ~> b
Simplex a b
ZZ = (Forget % a) ~> (Forget % b)
Fin Z -> Fin Z
forall a. Ob a => a -> a
forall {k} (p :: PRO k k) (a :: k). (Promonad p, Ob a) => p a a
id
  repMap (Y Simplex a y
f) = Fin y -> Fin (S y)
forall (n :: Nat). Fin n -> Fin (S n)
Fs (Fin y -> Fin (S y)) -> (Fin a -> Fin y) -> Fin a -> Fin (S y)
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
. forall {j} {k} (p :: j +-> k) (a :: j) (b :: j).
Representable p =>
(a ~> b) -> (p % a) ~> (p % b)
forall (p :: Nat +-> Type) (a :: Nat) (b :: Nat).
Representable p =>
(a ~> b) -> (p % a) ~> (p % b)
repMap @Forget a ~> y
Simplex a y
f
  repMap (X Simplex x (S y)
f) = \case
    Fin (S x)
Fz -> Fin (S y)
forall (n :: Nat). Fin (S n)
Fz
    Fs Fin n
n -> forall {j} {k} (p :: j +-> k) (a :: j) (b :: j).
Representable p =>
(a ~> b) -> (p % a) ~> (p % b)
forall (p :: Nat +-> Type) (a :: Nat) (b :: Nat).
Representable p =>
(a ~> b) -> (p % a) ~> (p % b)
repMap @Forget x ~> S y
Simplex x (S y)
f Fin n
n

type family (a :: Nat) + (b :: Nat) :: Nat where
  Z + b = b
  S a + b = S (a + b)

instance MonoidalProfunctor Simplex where
  par0 :: Simplex Unit Unit
par0 = Simplex Unit Unit
Simplex Z Z
ZZ
  Simplex x1 x2
ZZ par :: forall (x1 :: Nat) (x2 :: Nat) (y1 :: Nat) (y2 :: Nat).
Simplex x1 x2 -> Simplex y1 y2 -> Simplex (x1 ** y1) (x2 ** y2)
`par` Simplex y1 y2
g = Simplex y1 y2
Simplex (x1 ** y1) (x2 ** y2)
g
  Y Simplex x1 y
f `par` Simplex y1 y2
g = Simplex (x1 + y1) (y + y2) -> Simplex (x1 + y1) (S (y + y2))
forall (x :: Nat) (n :: Nat). Simplex x n -> Simplex x (S n)
Y (Simplex x1 y
f Simplex x1 y -> Simplex y1 y2 -> Simplex (x1 ** y1) (y ** y2)
forall {j} {k} (p :: j +-> k) (x1 :: k) (x2 :: j) (y1 :: k)
       (y2 :: j).
MonoidalProfunctor p =>
p x1 x2 -> p y1 y2 -> p (x1 ** y1) (x2 ** y2)
forall (x1 :: Nat) (x2 :: Nat) (y1 :: Nat) (y2 :: Nat).
Simplex x1 x2 -> Simplex y1 y2 -> Simplex (x1 ** y1) (x2 ** y2)
`par` Simplex y1 y2
g)
  X Simplex x (S y)
f `par` Simplex y1 y2
g = Simplex (x + y1) (S (y + y2)) -> Simplex (S (x + y1)) (S (y + y2))
forall (n :: Nat) (y :: Nat).
Simplex n (S y) -> Simplex (S n) (S y)
X (Simplex x (S y)
f Simplex x (S y) -> Simplex y1 y2 -> Simplex (x ** y1) (S y ** y2)
forall {j} {k} (p :: j +-> k) (x1 :: k) (x2 :: j) (y1 :: k)
       (y2 :: j).
MonoidalProfunctor p =>
p x1 x2 -> p y1 y2 -> p (x1 ** y1) (x2 ** y2)
forall (x1 :: Nat) (x2 :: Nat) (y1 :: Nat) (y2 :: Nat).
Simplex x1 x2 -> Simplex y1 y2 -> Simplex (x1 ** y1) (x2 ** y2)
`par` Simplex y1 y2
g)

instance Monoidal Nat where
  type Unit = Z
  type a ** b = a + b
  withOb2 :: forall (a :: Nat) (b :: Nat) r.
(Ob a, Ob b) =>
(Ob (a ** b) => r) -> r
withOb2 @a @b Ob (a ** b) => r
r = case forall (a :: Nat). IsNat a => SNat a
singNat @a of
    SNat a
SZ -> r
Ob (a ** b) => r
r
    SS @a' -> forall k (a :: k) (b :: k) r.
(Monoidal k, Ob a, Ob b) =>
(Ob (a ** b) => r) -> r
withOb2 @_ @a' @b r
Ob (a ** b) => r
Ob (n ** b) => r
r
  leftUnitor :: forall (a :: Nat). Ob a => (Unit ** a) ~> a
leftUnitor = (Unit ** a) ~> a
Simplex a a
forall {k} (p :: PRO k k) (a :: k). (Promonad p, Ob a) => p a a
forall (a :: Nat). Ob a => Simplex a a
id
  leftUnitorInv :: forall (a :: Nat). Ob a => a ~> (Unit ** a)
leftUnitorInv = a ~> (Unit ** a)
Simplex a a
forall {k} (p :: PRO k k) (a :: k). (Promonad p, Ob a) => p a a
forall (a :: Nat). Ob a => Simplex a a
id
  rightUnitor :: forall (a :: Nat). Ob a => (a ** Unit) ~> a
rightUnitor = (a ** Unit) ~> a
Simplex a a
forall {k} (p :: PRO k k) (a :: k). (Promonad p, Ob a) => p a a
forall (a :: Nat). Ob a => Simplex a a
id
  rightUnitorInv :: forall (a :: Nat). Ob a => a ~> (a ** Unit)
rightUnitorInv = a ~> (a ** Unit)
Simplex a a
forall {k} (p :: PRO k k) (a :: k). (Promonad p, Ob a) => p a a
forall (a :: Nat). Ob a => Simplex a a
id
  associator :: forall (a :: Nat) (b :: Nat) (c :: Nat).
(Ob a, Ob b, Ob c) =>
((a ** b) ** c) ~> (a ** (b ** c))
associator @a @b @c = forall k (a :: k) (b :: k) r.
(Monoidal k, Ob a, Ob b) =>
(Ob (a ** b) => r) -> r
withOb2 @_ @a @b (forall k (a :: k) (b :: k) r.
(Monoidal k, Ob a, Ob b) =>
(Ob (a ** b) => r) -> r
withOb2 @_ @(a ** b) @c (forall {k} (p :: PRO k k) (a :: k). (Promonad p, Ob a) => p a a
forall (p :: PRO Nat Nat) (a :: Nat). (Promonad p, Ob a) => p a a
id @Simplex))
  associatorInv :: forall (a :: Nat) (b :: Nat) (c :: Nat).
(Ob a, Ob b, Ob c) =>
(a ** (b ** c)) ~> ((a ** b) ** c)
associatorInv @a @b @c = forall k (a :: k) (b :: k) r.
(Monoidal k, Ob a, Ob b) =>
(Ob (a ** b) => r) -> r
withOb2 @_ @b @c (forall k (a :: k) (b :: k) r.
(Monoidal k, Ob a, Ob b) =>
(Ob (a ** b) => r) -> r
withOb2 @_ @a @(b ** c) (forall {k} (p :: PRO k k) (a :: k). (Promonad p, Ob a) => p a a
forall (p :: PRO Nat Nat) (a :: Nat). (Promonad p, Ob a) => p a a
id @Simplex))

instance Monoid (S Z) where
  mempty :: Unit ~> S Z
mempty = Simplex Z Z -> Simplex Z (S Z)
forall (x :: Nat) (n :: Nat). Simplex x n -> Simplex x (S n)
Y Simplex Z Z
ZZ
  mappend :: (S Z ** S Z) ~> S Z
mappend = Simplex (S Z) (S Z) -> Simplex (S (S Z)) (S Z)
forall (n :: Nat) (y :: Nat).
Simplex n (S y) -> Simplex (S n) (S y)
X (Simplex Z (S Z) -> Simplex (S Z) (S Z)
forall (n :: Nat) (y :: Nat).
Simplex n (S y) -> Simplex (S n) (S y)
X (Simplex Z Z -> Simplex Z (S Z)
forall (x :: Nat) (n :: Nat). Simplex x n -> Simplex x (S n)
Y Simplex Z Z
ZZ))

type Replicate :: k -> Nat +-> k
data Replicate m a b where
  Replicate :: (Ob b) => a ~> (Replicate m % b) -> Replicate m a b
instance (Monoid m) => Profunctor (Replicate m) where
  dimap :: forall (c :: j) (a :: j) (b :: Nat) (d :: Nat).
(c ~> a) -> (b ~> d) -> Replicate m a b -> Replicate m c d
dimap = (c ~> a) -> (b ~> d) -> Replicate m a b -> Replicate m c d
forall {j} {k} (p :: j +-> k) (a :: k) (b :: j) (c :: k) (d :: j).
Representable p =>
(c ~> a) -> (b ~> d) -> p a b -> p c d
dimapRep
  (Ob a, Ob b) => r
r \\ :: forall (a :: j) (b :: Nat) r.
((Ob a, Ob b) => r) -> Replicate m a b -> r
\\ Replicate a ~> (Replicate m % b)
f = r
(Ob a, Ob (Replicate m % b)) => r
(Ob a, Ob b) => r
r ((Ob a, Ob (Replicate m % b)) => r)
-> (a ~> (Replicate m % b)) -> r
forall (a :: j) (b :: j) r. ((Ob a, Ob b) => r) -> (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
\\ a ~> (Replicate m % b)
f
instance (Monoid m) => Representable (Replicate m) where
  type Replicate m % Z = Unit
  type Replicate m % S b = m ** (Replicate m % b)
  index :: forall (a :: k) (b :: Nat).
Replicate m a b -> a ~> (Replicate m % b)
index (Replicate a ~> (Replicate m % b)
f) = a ~> (Replicate m % b)
f
  tabulate :: forall (b :: Nat) (a :: k).
Ob b =>
(a ~> (Replicate m % b)) -> Replicate m a b
tabulate = (a ~> (Replicate m % b)) -> Replicate m a b
forall {k} (b :: Nat) (a :: k) (m :: k).
Ob b =>
(a ~> (Replicate m % b)) -> Replicate m a b
Replicate
  repMap :: forall (a :: Nat) (b :: Nat).
(a ~> b) -> (Replicate m % a) ~> (Replicate m % b)
repMap a ~> b
Simplex a b
ZZ = Unit ~> Unit
(Replicate m % a) ~> (Replicate m % b)
forall {j} {k} (p :: j +-> k). MonoidalProfunctor p => p Unit Unit
par0
  repMap (Y Simplex a y
f) = let g :: (Replicate m % a) ~> (Replicate m % y)
g = forall {j} {k} (p :: j +-> k) (a :: j) (b :: j).
Representable p =>
(a ~> b) -> (p % a) ~> (p % b)
forall (p :: Nat +-> k) (a :: Nat) (b :: Nat).
Representable p =>
(a ~> b) -> (p % a) ~> (p % b)
repMap @(Replicate m) a ~> y
Simplex a y
f in (forall (m :: k). Monoid m => Unit ~> m
forall {k} (m :: k). Monoid m => Unit ~> m
mempty @m (Unit ~> m)
-> ((Replicate m % a) ~> (Replicate m % y))
-> (Unit ** (Replicate m % a)) ~> (m ** (Replicate m % y))
forall (x1 :: k) (x2 :: k) (y1 :: k) (y2 :: k).
(x1 ~> x2) -> (y1 ~> y2) -> (x1 ** y1) ~> (x2 ** y2)
forall {j} {k} (p :: j +-> k) (x1 :: k) (x2 :: j) (y1 :: k)
       (y2 :: j).
MonoidalProfunctor p =>
p x1 x2 -> p y1 y2 -> p (x1 ** y1) (x2 ** y2)
`par` (Replicate m % a) ~> (Replicate m % y)
g) ((Unit ** (Replicate m % a)) ~> (m ** (Replicate m % y)))
-> ((Replicate m % a) ~> (Unit ** (Replicate m % a)))
-> (Replicate m % a) ~> (m ** (Replicate m % y))
forall (b :: k) (c :: k) (a :: k). (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
. (Replicate m % a) ~> (Unit ** (Replicate m % a))
forall (a :: k). Ob a => a ~> (Unit ** a)
forall k (a :: k). (Monoidal k, Ob a) => a ~> (Unit ** a)
leftUnitorInv ((Ob (Replicate m % a), Ob (Replicate m % y)) =>
 (Replicate m % a) ~> (m ** (Replicate m % y)))
-> ((Replicate m % a) ~> (Replicate m % y))
-> (Replicate m % a) ~> (m ** (Replicate m % y))
forall (a :: k) (b :: k) r. ((Ob a, Ob b) => r) -> (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
\\ (Replicate m % a) ~> (Replicate m % y)
g
  repMap (X (Y Simplex x y
f)) = forall (a :: k). (CategoryOf k, Ob a) => Obj a
forall {k} (a :: k). (CategoryOf k, Ob a) => Obj a
obj @m Obj m
-> ((Replicate m % x) ~> (Replicate m % y))
-> (m ** (Replicate m % x)) ~> (m ** (Replicate m % y))
forall (x1 :: k) (x2 :: k) (y1 :: k) (y2 :: k).
(x1 ~> x2) -> (y1 ~> y2) -> (x1 ** y1) ~> (x2 ** y2)
forall {j} {k} (p :: j +-> k) (x1 :: k) (x2 :: j) (y1 :: k)
       (y2 :: j).
MonoidalProfunctor p =>
p x1 x2 -> p y1 y2 -> p (x1 ** y1) (x2 ** y2)
`par` forall {j} {k} (p :: j +-> k) (a :: j) (b :: j).
Representable p =>
(a ~> b) -> (p % a) ~> (p % b)
forall (p :: Nat +-> k) (a :: Nat) (b :: Nat).
Representable p =>
(a ~> b) -> (p % a) ~> (p % b)
repMap @(Replicate m) x ~> y
Simplex x y
f
  repMap (X (X @x Simplex x (S y)
f)) =
    let g :: (Replicate m % S x) ~> (Replicate m % S y)
g = forall {j} {k} (p :: j +-> k) (a :: j) (b :: j).
Representable p =>
(a ~> b) -> (p % a) ~> (p % b)
forall (p :: Nat +-> k) (a :: Nat) (b :: Nat).
Representable p =>
(a ~> b) -> (p % a) ~> (p % b)
repMap @(Replicate m) (Simplex x (S y) -> Simplex (S x) (S y)
forall (n :: Nat) (y :: Nat).
Simplex n (S y) -> Simplex (S n) (S y)
X Simplex x (S y)
f)
        b :: (Replicate m % x) ~> (Replicate m % x)
b = forall {j} {k} (p :: j +-> k) (a :: j) (b :: j).
Representable p =>
(a ~> b) -> (p % a) ~> (p % b)
forall (p :: Nat +-> k) (a :: Nat) (b :: Nat).
Representable p =>
(a ~> b) -> (p % a) ~> (p % b)
repMap @(Replicate m) (Simplex x (S y) -> x ~> x
forall {k1} {k2} (a :: k2) (b :: k1) (p :: PRO k2 k1).
Profunctor p =>
p a b -> Obj a
src Simplex x (S y)
f)
    in (m ** (Replicate m % x)) ~> (m ** (Replicate m % y))
(Replicate m % S x) ~> (Replicate m % S y)
g ((m ** (Replicate m % x)) ~> (m ** (Replicate m % y)))
-> ((m ** (m ** (Replicate m % x))) ~> (m ** (Replicate m % x)))
-> (m ** (m ** (Replicate m % x))) ~> (m ** (Replicate m % y))
forall (b :: k) (c :: k) (a :: k). (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
. (forall (m :: k). Monoid m => (m ** m) ~> m
forall {k} (m :: k). Monoid m => (m ** m) ~> m
mappend @m ((m ** m) ~> m)
-> ((Replicate m % x) ~> (Replicate m % x))
-> ((m ** m) ** (Replicate m % x)) ~> (m ** (Replicate m % x))
forall (x1 :: k) (x2 :: k) (y1 :: k) (y2 :: k).
(x1 ~> x2) -> (y1 ~> y2) -> (x1 ** y1) ~> (x2 ** y2)
forall {j} {k} (p :: j +-> k) (x1 :: k) (x2 :: j) (y1 :: k)
       (y2 :: j).
MonoidalProfunctor p =>
p x1 x2 -> p y1 y2 -> p (x1 ** y1) (x2 ** y2)
`par` (Replicate m % x) ~> (Replicate m % x)
b) (((m ** m) ** (Replicate m % x)) ~> (m ** (Replicate m % x)))
-> ((m ** (m ** (Replicate m % x)))
    ~> ((m ** m) ** (Replicate m % x)))
-> (m ** (m ** (Replicate m % x))) ~> (m ** (Replicate m % x))
forall (b :: k) (c :: k) (a :: k). (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
. forall k (a :: k) (b :: k) (c :: k).
(Monoidal k, Ob a, Ob b, Ob c) =>
(a ** (b ** c)) ~> ((a ** b) ** c)
associatorInv @_ @m @m @(Replicate m % x) ((Ob (Replicate m % x), Ob (Replicate m % x)) =>
 (m ** (m ** (Replicate m % x))) ~> (m ** (Replicate m % y)))
-> ((Replicate m % x) ~> (Replicate m % x))
-> (m ** (m ** (Replicate m % x))) ~> (m ** (Replicate m % y))
forall (a :: k) (b :: k) r. ((Ob a, Ob b) => r) -> (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
\\ (Replicate m % x) ~> (Replicate m % x)
b