LaTeX-succeed.lagda 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. \documentclass{article}
  2. \usepackage{agda}
  3. \begin{document}
  4. \AgdaHide{
  5. \begin{code}
  6. module LaTeX-succeed where
  7. \end{code}
  8. }
  9. \begin{code}
  10. data Bool : Set where
  11. true : Bool
  12. false : Bool
  13. if_then_else_ : {A : Set} → Bool → A → A → A
  14. if true then t else f = t
  15. if false then t else f = f
  16. data ℕ : Set where
  17. zero : ℕ
  18. suc : ℕ → ℕ
  19. _+_ : ℕ → ℕ → ℕ
  20. zero + n = n
  21. suc m {- ugh -} + n = suc (m + n)
  22. {-# BUILTIN NATURAL ℕ #-}
  23. alignment : (m n o p : ℕ) → ℕ
  24. alignment 0 1 2 3 = 4
  25. alignment 1 2 3 4 = 5
  26. alignment 2 3 4 5 = 6
  27. alignment _ _ _ _ = 0
  28. \end{code}
  29. \begin{code}
  30. data ⊥ : Set where
  31. record R : Set₁ where
  32. field
  33. f : Set
  34. g : Set
  35. record R′ (A B : Set) : Set₁ where
  36. field
  37. h : Set
  38. j : Set
  39. r : R
  40. \end{code}
  41. \begin{code}
  42. module M where
  43. r′ : ∀ {A B : Set} → R′ A B
  44. r′ = record
  45. { h = ⊥
  46. ; j = ⊥
  47. ; r = record
  48. { f = ⊥
  49. ; g = ⊥
  50. }
  51. }
  52. \end{code}
  53. Andreas, 2018-04-03: The following two modules test the highlighting of projection patterns.
  54. \begin{code}
  55. module QualifiedProjectionPatterns where
  56. r : R
  57. r .R.f = Bool
  58. r .R.g = ⊥
  59. r′ : R′ Bool ⊥
  60. R′.h r′ = ⊥
  61. R′.j r′ = Bool → Bool
  62. R′.r r′ = r
  63. \end{code}
  64. \begin{code}
  65. module UnqualifiedProjectionPatterns where
  66. open R; open R′
  67. r₀ : R
  68. r₀ .f = Bool
  69. r₀ .g = ⊥
  70. r′ : R′ Bool ⊥
  71. h r′ = ⊥
  72. j r′ = Bool → Bool
  73. r r′ = r₀
  74. \end{code}
  75. \end{document}