{-# OPTIONS_GHC -Wno-orphans #-}

module Proarrow.Promonad
  ( Promonad (..)
  , Procomonad (..)
  ) where

import Proarrow.Core (CAT, CategoryOf, Profunctor, Promonad (..), src, (:~>), type (~>))
import Proarrow.Profunctor.Composition ((:.:) (..))
import Proarrow.Profunctor.Identity (Id (..))

class (Profunctor p) => Procomonad p where
  extract :: p :~> (~>)
  duplicate :: p :~> p :.: p

instance (CategoryOf k) => Procomonad (Id :: CAT k) where
  extract :: Id :~> (~>)
extract (Id a ~> b
f) = a ~> b
f
  duplicate :: Id :~> (Id :.: Id)
duplicate (Id a ~> b
f) = (a ~> a) -> Id a a
forall k (a :: k) (b :: k). (a ~> b) -> Id a b
Id ((a ~> b) -> a ~> a
forall {k1} {k2} (a :: k2) (b :: k1) (p :: PRO k2 k1).
Profunctor p =>
p a b -> Obj a
src a ~> b
f) Id a a -> Id a b -> (:.:) Id Id 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
:.: (a ~> b) -> Id a b
forall k (a :: k) (b :: k). (a ~> b) -> Id a b
Id a ~> b
f