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
35 | constructor MkPromonad
38 | fromFunc : (a -> b) -> cat a b
45 | interface Category cat => Promonad0 (0 cat : Hom Type0) where
46 | constructor MkPromonad0
49 | fromFuncW : (a -> b) -> cat (W0 a) (W0 b)
57 | [PromonadUnit] Promonad cat => CatFunctor Morphism cat Prelude.id where
58 | map = fromFunc . applyMor
62 | [PromonadUnit0] Promonad0 cat => CatFunctor Morphism cat (\x => W0 x) where
63 | map = fromFuncW . applyMor
68 | [FromPromonad] {ten,i : _} -> (Promonad cat, CatEndoBifunctor cat ten, Monoidal Morphism ten i) =>
69 | Monoidal cat ten i where
70 | assoc = fromFunc $
applyMor assoc
71 | assoc' = fromFunc $
applyMor assoc'
72 | unitl = fromFunc $
applyMor unitl
73 | unitl' = fromFunc $
applyMor unitl'
74 | unitr = fromFunc $
applyMor unitr
75 | unitr' = fromFunc $
applyMor unitr'
80 | [FromPromonad] {ten,i : _} -> (Promonad cat, CatEndoBifunctor cat ten, Braided Morphism ten i) =>
81 | Braided cat ten i using Monoidal.FromPromonad where
82 | braid = fromFunc $
applyMor braid
84 | namespace MonSymmetric
87 | [FromPromonad] {ten,i : _} -> (Promonad cat, CatEndoBifunctor cat ten, MonSymmetric Morphism ten i) =>
88 | MonSymmetric cat ten i using Braided.FromPromonad where
93 | [FromPromonad] {ten,i : _} -> (Promonad cat, CatEndoBifunctor cat ten, Cartesian Morphism ten i) =>
94 | Cartesian cat ten i using Monoidal.FromPromonad where
95 | projl = fromFunc $
applyMor projl
96 | projr = fromFunc $
applyMor projr
97 | prod f g = Core.(.) {cat} (bimap' f g) (split {cat,ten,i})
98 | split = fromFunc $
applyMor split
99 | elim = fromFunc $
applyMor $
elim {ten}
101 | namespace Cocartesian
104 | [FromPromonad] {ten,i : _} -> (Promonad cat, CatEndoBifunctor cat ten, Cocartesian Morphism ten i) =>
105 | Cocartesian cat ten i using Monoidal.FromPromonad where
106 | injl = fromFunc $
applyMor injl
107 | injr = fromFunc $
applyMor injr
108 | coprod f g = Core.(.) {cat} (merge {cat,ten,i}) (bimap' f g)
109 | merge = fromFunc $
applyMor merge
110 | intro = fromFunc $
applyMor $
intro {ten}
112 | namespace Bimonoidal
115 | [FromPromonad] {add,mul,z,i : _} -> (Promonad cat, CatEndoBifunctor cat add, CatEndoBifunctor cat mul,
116 | Bimonoidal Morphism add mul z i) => Bimonoidal cat add mul z i
117 | using Monoidal.FromPromonad where
118 | distribl = fromFunc $
applyMor distribl
119 | distribl' = fromFunc $
applyMor distribl'
120 | distribr = fromFunc $
applyMor distribr
121 | distribr' = fromFunc $
applyMor distribr'
122 | absorbl = fromFunc $
applyMor $
absorbl {add,mul}
123 | absorbl' = fromFunc $
applyMor $
absorbl' {add,mul}
124 | absorbr = fromFunc $
applyMor $
absorbr {add,mul}
125 | absorbr' = fromFunc $
applyMor $
absorbr' {add,mul}
133 | Promonad Morphism where
138 | [Function] Promonad (~~>) using Category.Function where
142 | Monad m => Promonad (Kleislimorphism m) where
143 | fromFunc f = Kleisli $
pure . f