Implement monads in the kleisli form

This commit is contained in:
Frederik Hanghøj Iversen 2018-02-24 14:00:52 +01:00
parent 0ca11874bc
commit 4ec13fe509
2 changed files with 43 additions and 2 deletions

View file

@ -4,3 +4,11 @@ Backlog
Prove univalence for various categories
Prove postulates in `Cat.Wishlist`
* Functor ✓
* Applicative Functor ✗
* Lax monoidal functor ✗
* Monoidal functor ✗
* Tensorial strength ✗
* Category ✓
* Monoidal category ✗

View file

@ -27,9 +27,10 @@ module Monoidal {a b : Level} ( : Category a b) where
-- (>=>)
μNat : NaturalTransformation F[ R R ] R
module R = Functor R
module RR = Functor F[ R R ]
private
module R = Functor R
module RR = Functor F[ R R ]
module _ {X : Object} where
-- module IdRX = Functor (F.identity {C = RX})
@ -69,3 +70,35 @@ module Monoidal {a b : Level} ( : Category a b) where
field
isAssociative : IsAssociative
isInverse : IsInverse
-- "A monad in the Kleisli form" [vlad]
module Kleisli {a b : Level} ( : Category a b) where
private
= a b
open Category hiding (IsIdentity)
record RawMonad : Set where
field
RR : Object Object
η : {X : Object} [ X , RR X ]
rr : {X Y : Object} [ X , RR Y ] [ RR X , RR Y ]
-- Name suggestions are welcome!
IsIdentity = {X : Object}
rr η 𝟙 {RR X}
IsNatural = {X Y : Object} (f : [ X , RR Y ])
( [ rr f η ]) f
IsDistributive = {X Y Z : Object} (g : [ Y , RR Z ]) (f : [ X , RR Y ])
[ rr g rr f ] rr ( [ rr g f ])
record IsMonad (raw : RawMonad) : Set where
open RawMonad raw public
field
isIdentity : IsIdentity
isNatural : IsNatural
isDistributive : IsDistributive
record Monad : Set where
field
raw : RawMonad
isMonad : IsMonad raw
open IsMonad isMonad public