mirror of
https://git8.cs.fau.de/theses/bsc-leon-vatthauer.git
synced 2024-05-31 07:28:34 +02:00
Work on maybe
This commit is contained in:
parent
7be2f41196
commit
b63d5455be
1 changed files with 16 additions and 6 deletions
|
@ -25,8 +25,8 @@ open import Function.Base using (id)
|
||||||
-->
|
-->
|
||||||
|
|
||||||
```agda
|
```agda
|
||||||
module Monad.Instance.K.Instance.Maybe {o ℓ e} (ambient : Ambient o ℓ e) where
|
-- TODO arguments c ℓ here!
|
||||||
open Ambient ambient using ()
|
module Monad.Instance.K.Instance.Maybe {o ℓ e} where
|
||||||
```
|
```
|
||||||
|
|
||||||
# The Maybe Monad as instance of K
|
# The Maybe Monad as instance of K
|
||||||
|
@ -85,12 +85,18 @@ module _ {c ℓ : Level} where
|
||||||
|
|
||||||
maybeFun-comp : ∀ {A B C : Setoid c ℓ} (f : A ⟶ B) (g : B ⟶ C) → maybeFun (g ∘ f) ≋ ((maybeFun g) ∘ (maybeFun f))
|
maybeFun-comp : ∀ {A B C : Setoid c ℓ} (f : A ⟶ B) (g : B ⟶ C) → maybeFun (g ∘ f) ≋ ((maybeFun g) ∘ (maybeFun f))
|
||||||
maybeFun-comp {A} {B} {C} f g {nothing} {nothing} i≈j = i≈j
|
maybeFun-comp {A} {B} {C} f g {nothing} {nothing} i≈j = i≈j
|
||||||
maybeFun-comp {A} {B} {C} f g {just i} {just j} i≈j = cong g (cong f i≈j)
|
maybeFun-comp {A} {B} {C} f g {just _} {just _} i≈j = cong g (cong f i≈j)
|
||||||
|
|
||||||
|
maybeFun-resp-≈ : ∀ {A B : Setoid c ℓ} {f g : A ⟶ B} → f ≋ g → maybeFun f ≋ maybeFun g
|
||||||
|
maybeFun-resp-≈ {A} {B} {f} {g} f≈g {nothing} {nothing} i≈j = i≈j
|
||||||
|
maybeFun-resp-≈ {A} {B} {f} {g} f≈g {just _} {just _} i≈j = f≈g i≈j
|
||||||
|
|
||||||
η : ∀ (A : Setoid c ℓ) → A ⟶ maybeSetoid A
|
η : ∀ (A : Setoid c ℓ) → A ⟶ maybeSetoid A
|
||||||
η A = record { _⟨$⟩_ = just ; cong = id }
|
η A = record { _⟨$⟩_ = just ; cong = id }
|
||||||
|
|
||||||
|
η-natural : ∀ {A B : Setoid c ℓ} (f : A ⟶ B) → (η B ∘ f) ≋ (maybeFun f ∘ η A)
|
||||||
|
η-natural {A} {B} f {i} {j} i≈j = cong f i≈j
|
||||||
|
|
||||||
μ : ∀ (A : Setoid c ℓ) → maybeSetoid (maybeSetoid A) ⟶ maybeSetoid A
|
μ : ∀ (A : Setoid c ℓ) → maybeSetoid (maybeSetoid A) ⟶ maybeSetoid A
|
||||||
μ A = record { _⟨$⟩_ = app ; cong = λ {i} {j} → cong' i j }
|
μ A = record { _⟨$⟩_ = app ; cong = λ {i} {j} → cong' i j }
|
||||||
where
|
where
|
||||||
|
@ -101,6 +107,10 @@ module _ {c ℓ : Level} where
|
||||||
cong' nothing nothing i≈j = i≈j
|
cong' nothing nothing i≈j = i≈j
|
||||||
cong' (just i) (just j) i≈j = i≈j
|
cong' (just i) (just j) i≈j = i≈j
|
||||||
|
|
||||||
|
μ-natural : ∀ {A B : Setoid c ℓ} (f : A ⟶ B) → (μ B ∘ maybeFun (maybeFun f)) ≋ (maybeFun f ∘ μ A)
|
||||||
|
μ-natural {A} {B} f {nothing} {nothing} i≈j = i≈j
|
||||||
|
μ-natural {A} {B} f {just i} {just j} i≈j = cong (maybeFun f) {i} {j} i≈j
|
||||||
|
|
||||||
maybeMonad : Monad (Setoids c ℓ)
|
maybeMonad : Monad (Setoids c ℓ)
|
||||||
maybeMonad = record
|
maybeMonad = record
|
||||||
{ F = record
|
{ F = record
|
||||||
|
@ -108,15 +118,15 @@ module _ {c ℓ : Level} where
|
||||||
; F₁ = maybeFun
|
; F₁ = maybeFun
|
||||||
; identity = λ {A} {x} {y} → maybeFun-id {A = A} {x} {y}
|
; identity = λ {A} {x} {y} → maybeFun-id {A = A} {x} {y}
|
||||||
; homomorphism = λ {A} {B} {C} {f} {g} {i} {j} → maybeFun-comp {A} {B} {C} f g {i} {j}
|
; homomorphism = λ {A} {B} {C} {f} {g} {i} {j} → maybeFun-comp {A} {B} {C} f g {i} {j}
|
||||||
; F-resp-≈ = {! !}
|
; F-resp-≈ = maybeFun-resp-≈
|
||||||
}
|
}
|
||||||
; η = ntHelper (record
|
; η = ntHelper (record
|
||||||
{ η = η
|
{ η = η
|
||||||
; commute = {! !}
|
; commute = η-natural
|
||||||
})
|
})
|
||||||
; μ = ntHelper (record
|
; μ = ntHelper (record
|
||||||
{ η = μ
|
{ η = μ
|
||||||
; commute = {! !}
|
; commute = μ-natural
|
||||||
})
|
})
|
||||||
; assoc = {! !}
|
; assoc = {! !}
|
||||||
; sym-assoc = {! !}
|
; sym-assoc = {! !}
|
||||||
|
|
Loading…
Reference in a new issue