telescopes.lagda.rst 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. ..
  2. ::
  3. module language.telescopes where
  4. .. _telescopes:
  5. **********
  6. Telescopes
  7. **********
  8. .. note::
  9. This is a stub.
  10. Irrefutable Patterns in Binding Positions
  11. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  12. ..
  13. ::
  14. module pattern-tele where
  15. open import Agda.Builtin.Sigma
  16. open import Agda.Builtin.Equality
  17. private
  18. variable
  19. A : Set
  20. B : A → Set
  21. Since Agda 2.6.1, irrefutable patterns can be used at every binding site in a
  22. telescope to take the bound value of record type apart. The type of the second
  23. projection out of a dependent pair will for instance naturally mention the value
  24. of the first projection. Its type can be defined directly using an irrefutable
  25. pattern as follows:
  26. ::
  27. proj₂ : ((a , _) : Σ A B) → B a
  28. And this second projection can be implemented with a lamba-abstraction using
  29. one of these irrefutable patterns taking the pair apart:
  30. ::
  31. proj₂ = λ (_ , b) → b
  32. Using an as-pattern makes it possible to name the argument and to take it
  33. apart at the same time. We can for instance prove that any pair is equal
  34. to the pairing of its first and second projections, a property commonly
  35. called eta-equality:
  36. ::
  37. eta : (p@(a , b) : Σ A B) → p ≡ (a , b)
  38. eta p = refl