Sum.agda 406 B

123456789101112131415
  1. module Common.Sum where
  2. open import Common.Level
  3. data _⊎_ {a b} (A : Set a) (B : Set b) : Set (a ⊔ b) where
  4. inj₁ : (x : A) → A ⊎ B
  5. inj₂ : (y : B) → A ⊎ B
  6. [_,_] : ∀ {a b c} {A : Set a} {B : Set b} {C : A ⊎ B → Set c} →
  7. ((x : A) → C (inj₁ x)) → ((x : B) → C (inj₂ x)) →
  8. ((x : A ⊎ B) → C x)
  9. [ f , g ] (inj₁ x) = f x
  10. [ f , g ] (inj₂ y) = g y