0 | module Control.Category.Promonad
2 | import Control.Category.Core
3 | import Control.Category.Semigroupoid
4 | import Control.Category.Functor
5 | import Control.Category.Monoidal
6 | import Control.Category.Braided
7 | import Control.Category.Cartesian
8 | import Control.Category.Cocartesian
9 | import Control.Category.Traced
10 | import Control.Category.Bimonoidal
11 | import Data.Profunctor
12 | import Data.Profunctor.Costrong
14 | import Data.Morphisms
34 | interface Category cat => Promonad (0 cat : Hom Type) where
37 | fromFunc : (a -> b) -> cat a b
44 | interface Category cat => Promonad0 (0 cat : Hom Type0) where
47 | fromFuncW : (a -> b) -> cat (W0 a) (W0 b)
55 | [PromonadUnit] Promonad cat => CatFunctor Morphism cat Prelude.id where
56 | map = fromFunc . applyMor
60 | [PromonadUnit0] Promonad0 cat => CatFunctor Morphism cat (\x => W0 x) where
61 | map = fromFuncW . applyMor
66 | [FromPromonad] {ten,i : _} -> (Promonad cat, CatEndoBifunctor cat ten, Monoidal Morphism ten i) =>
67 | Monoidal cat ten i where
68 | assoc = fromFunc $
applyMor assoc
69 | assoc' = fromFunc $
applyMor assoc'
70 | unitl = fromFunc $
applyMor unitl
71 | unitl' = fromFunc $
applyMor unitl'
72 | unitr = fromFunc $
applyMor unitr
73 | unitr' = fromFunc $
applyMor unitr'
78 | [FromPromonad] {ten,i : _} -> (Promonad cat, CatEndoBifunctor cat ten, Braided Morphism ten i) =>
79 | Braided cat ten i using Monoidal.FromPromonad where
80 | braid = fromFunc $
applyMor braid
82 | namespace MonSymmetric
85 | [FromPromonad] {ten,i : _} -> (Promonad cat, CatEndoBifunctor cat ten, MonSymmetric Morphism ten i) =>
86 | MonSymmetric cat ten i using Braided.FromPromonad where
91 | [FromPromonad] {ten,i : _} -> (Promonad cat, CatEndoBifunctor cat ten, Cartesian Morphism ten i) =>
92 | Cartesian cat ten i using Monoidal.FromPromonad where
93 | projl = fromFunc $
applyMor projl
94 | projr = fromFunc $
applyMor projr
95 | prod f g = Core.(.) {cat} (bimap' f g) (split {cat,ten,i})
96 | split = fromFunc $
applyMor split
97 | elim = fromFunc $
applyMor $
elim {ten}
99 | namespace Cocartesian
102 | [FromPromonad] {ten,i : _} -> (Promonad cat, CatEndoBifunctor cat ten, Cocartesian Morphism ten i) =>
103 | Cocartesian cat ten i using Monoidal.FromPromonad where
104 | injl = fromFunc $
applyMor injl
105 | injr = fromFunc $
applyMor injr
106 | coprod f g = Core.(.) {cat} (merge {cat,ten,i}) (bimap' f g)
107 | merge = fromFunc $
applyMor merge
108 | intro = fromFunc $
applyMor $
intro {ten}
110 | namespace Bimonoidal
113 | [FromPromonad] {add,mul,z,i : _} -> (Promonad cat, CatEndoBifunctor cat add, CatEndoBifunctor cat mul,
114 | Bimonoidal Morphism add mul z i) => Bimonoidal cat add mul z i
115 | using Monoidal.FromPromonad where
116 | distribl = fromFunc $
applyMor distribl
117 | distribl' = fromFunc $
applyMor distribl'
118 | distribr = fromFunc $
applyMor distribr
119 | distribr' = fromFunc $
applyMor distribr'
120 | absorbl = fromFunc $
applyMor $
absorbl {add,mul}
121 | absorbl' = fromFunc $
applyMor $
absorbl' {add,mul}
122 | absorbr = fromFunc $
applyMor $
absorbr {add,mul}
123 | absorbr' = fromFunc $
applyMor $
absorbr' {add,mul}
131 | Promonad Morphism where
136 | [Function] Promonad (~~>) using Category.Function where
140 | Monad m => Promonad (Kleislimorphism m) where
141 | fromFunc f = Kleisli $
pure . f