Rename RR to Romap

This commit is contained in:
Frederik Hanghøj Iversen 2018-03-06 09:55:18 +01:00
parent c57cd5c991
commit bdd67aee53

View file

@ -166,23 +166,23 @@ module Kleisli {a b : Level} ( : Category a b) where
-- are not generally types. -- are not generally types.
record RawMonad : Set where record RawMonad : Set where
field field
RR : Object Object Romap : Object Object
-- Note name-change from [voe] -- Note name-change from [voe]
pure : {X : Object} [ X , RR X ] pure : {X : Object} [ X , Romap X ]
bind : {X Y : Object} [ X , RR Y ] [ RR X , RR Y ] bind : {X Y : Object} [ X , Romap Y ] [ Romap X , Romap Y ]
-- | functor map -- | functor map
-- --
-- This should perhaps be defined in a "Klesli-version" of functors as well? -- This should perhaps be defined in a "Klesli-version" of functors as well?
fmap : {A B} [ A , B ] [ RR A , RR B ] fmap : {A B} [ A , B ] [ Romap A , Romap B ]
fmap f = bind (pure f) fmap f = bind (pure f)
-- | Composition of monads aka. the kleisli-arrow. -- | Composition of monads aka. the kleisli-arrow.
_>=>_ : {A B C : Object} [ A , RR B ] [ B , RR C ] [ A , RR C ] _>=>_ : {A B C : Object} [ A , Romap B ] [ B , Romap C ] [ A , Romap C ]
f >=> g = f >>> (bind g) f >=> g = f >>> (bind g)
-- | Flattening nested monads. -- | Flattening nested monads.
join : {A : Object} [ RR (RR A) , RR A ] join : {A : Object} [ Romap (Romap A) , Romap A ]
join = bind 𝟙 join = bind 𝟙
------------------ ------------------
@ -192,10 +192,10 @@ module Kleisli {a b : Level} ( : Category a b) where
-- There may be better names than what I've chosen here. -- There may be better names than what I've chosen here.
IsIdentity = {X : Object} IsIdentity = {X : Object}
bind pure 𝟙 {RR X} bind pure 𝟙 {Romap X}
IsNatural = {X Y : Object} (f : [ X , RR Y ]) IsNatural = {X Y : Object} (f : [ X , Romap Y ])
pure >>> (bind f) f pure >>> (bind f) f
IsDistributive = {X Y Z : Object} (g : [ Y , RR Z ]) (f : [ X , RR Y ]) IsDistributive = {X Y Z : Object} (g : [ Y , Romap Z ]) (f : [ X , Romap Y ])
(bind f) >>> (bind g) bind (f >=> g) (bind f) >>> (bind g) bind (f >=> g)
-- | Functor map fusion. -- | Functor map fusion.
@ -239,7 +239,7 @@ module Kleisli {a b : Level} ( : Category a b) where
-- | This formulation gives rise to the following endo-functor. -- | This formulation gives rise to the following endo-functor.
private private
rawR : RawFunctor rawR : RawFunctor
RawFunctor.func* rawR = RR RawFunctor.func* rawR = Romap
RawFunctor.func→ rawR = fmap RawFunctor.func→ rawR = fmap
isFunctorR : IsFunctor rawR isFunctorR : IsFunctor rawR
@ -399,25 +399,23 @@ module _ {a b : Level} { : Category a b} where
open using (Object ; Arrow ; 𝟙 ; _∘_ ; _>>>_) open using (Object ; Arrow ; 𝟙 ; _∘_ ; _>>>_)
open Functor using (func* ; func→) open Functor using (func* ; func→)
module M = Monoidal module M = Monoidal
module K = Kleisli module K = Kleisli
-- Note similarity with locally defined things in Kleisly.RawMonad!!
module _ (m : M.RawMonad) where module _ (m : M.RawMonad) where
open M.RawMonad m open M.RawMonad m
forthRaw : K.RawMonad forthRaw : K.RawMonad
K.RawMonad.RR forthRaw = Romap K.RawMonad.Romap forthRaw = Romap
K.RawMonad.pure forthRaw = pureT _ K.RawMonad.pure forthRaw = pureT _
K.RawMonad.bind forthRaw = bind K.RawMonad.bind forthRaw = bind
module _ {raw : M.RawMonad} (m : M.IsMonad raw) where module _ {raw : M.RawMonad} (m : M.IsMonad raw) where
private private
module MI = M.IsMonad m module MI = M.IsMonad m
module KI = K.IsMonad
forthIsMonad : K.IsMonad (forthRaw raw) forthIsMonad : K.IsMonad (forthRaw raw)
KI.isIdentity forthIsMonad = proj₂ MI.isInverse K.IsMonad.isIdentity forthIsMonad = proj₂ MI.isInverse
KI.isNatural forthIsMonad = MI.isNatural K.IsMonad.isNatural forthIsMonad = MI.isNatural
KI.isDistributive forthIsMonad = MI.isDistributive K.IsMonad.isDistributive forthIsMonad = MI.isDistributive
forth : M.Monad K.Monad forth : M.Monad K.Monad
Kleisli.Monad.raw (forth m) = forthRaw (M.Monad.raw m) Kleisli.Monad.raw (forth m) = forthRaw (M.Monad.raw m)
@ -430,7 +428,7 @@ module _ {a b : Level} { : Category a b} where
module MI = M.IsMonad module MI = M.IsMonad
backRaw : M.RawMonad backRaw : M.RawMonad
MR.R backRaw = R MR.R backRaw = R
MR.pureNT backRaw = pureNT MR.pureNT backRaw = pureNT
MR.joinNT backRaw = joinNT MR.joinNT backRaw = joinNT
@ -476,7 +474,7 @@ module _ {a b : Level} { : Category a b} where
bind bind
where where
joinT = proj₁ joinNT joinT = proj₁ joinNT
lem : (f : Arrow X (RR Y)) bind (f >>> pure) >>> bind 𝟙 bind f lem : (f : Arrow X (Romap Y)) bind (f >>> pure) >>> bind 𝟙 bind f
lem f = begin lem f = begin
bind (f >>> pure) >>> bind 𝟙 bind (f >>> pure) >>> bind 𝟙
≡⟨ isDistributive _ _ ≡⟨ isDistributive _ _
@ -492,7 +490,7 @@ module _ {a b : Level} { : Category a b} where
x & f = f x x & f = f x
forthRawEq : forthRaw (backRaw m) K.Monad.raw m forthRawEq : forthRaw (backRaw m) K.Monad.raw m
K.RawMonad.RR (forthRawEq _) = RR K.RawMonad.Romap (forthRawEq _) = Romap
K.RawMonad.pure (forthRawEq _) = pure K.RawMonad.pure (forthRawEq _) = pure
-- stuck -- stuck
K.RawMonad.bind (forthRawEq i) = bindEq i K.RawMonad.bind (forthRawEq i) = bindEq i