FunctorComposition.agda 1.0 KB

12345678910111213141516171819202122232425262728
  1. module FunctorComposition where
  2. open import Functor as F
  3. compose : {F₁ F₂ : Setoid → Setoid} →
  4. Functor F₁ → Functor F₂ → Functor (λ A → F₁ (F₂ A))
  5. compose {F₁} {F₂} FF₁ FF₂ = record
  6. { map = map FF₁ ∘ map FF₂
  7. ; identity = λ {A} →
  8. trans (F₁ (F₂ A) ⇨ F₁ (F₂ A))
  9. {i = map FF₁ ⟨$⟩ (map FF₂ ⟨$⟩ id)}
  10. {j = map FF₁ ⟨$⟩ id}
  11. {k = id}
  12. (cong (map FF₁) (identity FF₂))
  13. (identity FF₁)
  14. ; composition = λ {A B C} f g →
  15. trans (F₁ (F₂ A) ⇨ F₁ (F₂ C))
  16. {i = map FF₁ ⟨$⟩ (map FF₂ ⟨$⟩ (f ∘ g))}
  17. {j = map FF₁ ⟨$⟩ ((map FF₂ ⟨$⟩ f) ∘ (map FF₂ ⟨$⟩ g))}
  18. {k = (map FF₁ ⟨$⟩ (map FF₂ ⟨$⟩ f)) ∘
  19. (map FF₁ ⟨$⟩ (map FF₂ ⟨$⟩ g))}
  20. (cong (map FF₁) (composition FF₂ f g))
  21. (composition FF₁ (map FF₂ ⟨$⟩ f) (map FF₂ ⟨$⟩ g))
  22. }
  23. where
  24. open Setoid
  25. open F.Functor