Rename zeta to pure

This commit is contained in:
Frederik Hanghøj Iversen 2018-02-26 19:58:27 +01:00
parent 043641462d
commit 47882b1110

View file

@ -74,12 +74,10 @@ module Kleisli {a b : Level} ( : Category a b) where
field
RR : Object Object
-- Note name-change from [voe]
ζ : {X : Object} [ X , RR X ]
pure : {X : Object} [ X , RR X ]
bind : {X Y : Object} [ X , RR Y ] [ RR X , RR Y ]
pure : {X : Object} [ X , RR X ]
pure = ζ
fmap : {A B} [ A , B ] [ RR A , RR B ]
fmap f = bind (ζ f)
fmap f = bind (pure f)
-- Why is (>>=) not implementable? - Because in e.g. the category of sets is
-- `m a` a set. This is not necessarily the case.
--
@ -126,12 +124,12 @@ module Kleisli {a b : Level} ( : Category a b) where
bind ((fmap g pure) f) ≡⟨ cong bind (sym isAssociative)
bind
(fmap g (pure f)) ≡⟨ sym lem
bind (ζ g) bind (ζ f) ≡⟨⟩
bind (pure g) bind (pure f) ≡⟨⟩
fmap g fmap f
where
open Category using (isAssociative)
lem : fmap g fmap f bind (fmap g (pure f))
lem = isDistributive (ζ g) (ζ f)
lem = isDistributive (pure g) (pure f)
record Monad : Set where
field
@ -165,15 +163,15 @@ module _ {a b : Level} { : Category a b} where
RR : Object Object
RR = func* R
ζ : {X : Object} [ X , RR X ]
ζ {X} = η X
pure : {X : Object} [ X , RR X ]
pure {X} = η X
bind : {X Y : Object} [ X , RR Y ] [ RR X , RR Y ]
bind {X} {Y} f = μ Y func→ R f
forthRaw : K.RawMonad
Kraw.RR forthRaw = RR
Kraw.ζ forthRaw = ζ
Kraw.pure forthRaw = pure
Kraw.bind forthRaw = bind
module _ {raw : M.RawMonad} (m : M.IsMonad raw) where
@ -184,7 +182,7 @@ module _ {a b : Level} { : Category a b} where
isIdentity : IsIdentity
isIdentity {X} = begin
bind ζ ≡⟨⟩
bind pure ≡⟨⟩
bind (η X) ≡⟨⟩
μ X func→ R (η X) ≡⟨ proj₂ isInverse
𝟙
@ -192,7 +190,7 @@ module _ {a b : Level} { : Category a b} where
module R = Functor R
isNatural : IsNatural
isNatural {X} {Y} f = begin
bind f ζ ≡⟨⟩
bind f pure ≡⟨⟩
bind f η X ≡⟨⟩
μ Y R.func→ f η X ≡⟨ sym .isAssociative
μ Y (R.func→ f η X) ≡⟨ cong (λ φ μ Y φ) (sym (ηN f))
@ -260,18 +258,18 @@ module _ {a b : Level} { : Category a b} where
rawR : RawFunctor
RawFunctor.func* rawR = RR
RawFunctor.func→ rawR f = bind (ζ f)
RawFunctor.func→ rawR f = bind (pure f)
isFunctorR : IsFunctor rawR
IsFunctor.isIdentity isFunctorR = begin
bind (ζ 𝟙) ≡⟨ cong bind (proj₁ .isIdentity)
bind ζ ≡⟨ isIdentity
bind (pure 𝟙) ≡⟨ cong bind (proj₁ .isIdentity)
bind pure ≡⟨ isIdentity
𝟙
IsFunctor.isDistributive isFunctorR {f = f} {g} = begin
bind (ζ (g f)) ≡⟨⟩
bind (pure (g f)) ≡⟨⟩
fmap (g f) ≡⟨ fusion
fmap g fmap f ≡⟨⟩
bind (ζ g) bind (ζ f)
bind (pure g) bind (pure f)
R : Functor
Functor.raw R = rawR
@ -308,7 +306,7 @@ module _ {a b : Level} { : Category a b} where
open K.RawMonad (K.Monad.raw m)
forthRawEq : forthRaw (backRaw m) K.Monad.raw m
K.RawMonad.RR (forthRawEq _) = RR
K.RawMonad.ζ (forthRawEq _) = ζ
K.RawMonad.pure (forthRawEq _) = pure
-- stuck
K.RawMonad.bind (forthRawEq i) = {!!}