InfixDeclaration.tex 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. \documentclass{article}
  2. \usepackage{agda}
  3. \begin{document}
  4. \begin{code}%
  5. \>[0]\AgdaKeyword{module}\AgdaSpace{}%
  6. \AgdaModule{InfixDeclaration}\AgdaSpace{}%
  7. \AgdaKeyword{where}\<%
  8. \\
  9. %
  10. \\[\AgdaEmptyExtraSkip]%
  11. \>[0]\AgdaKeyword{infix}\AgdaSpace{}%
  12. \AgdaNumber{5}\AgdaSpace{}%
  13. \AgdaOperator{\AgdaDatatype{\AgdaUnderscore{}>>\AgdaUnderscore{}}}\AgdaSpace{}%
  14. \AgdaOperator{\AgdaDatatype{\AgdaUnderscore{}<<\AgdaUnderscore{}}}\<%
  15. \\
  16. %
  17. \\[\AgdaEmptyExtraSkip]%
  18. \>[0]\AgdaKeyword{data}\AgdaSpace{}%
  19. \AgdaOperator{\AgdaDatatype{\AgdaUnderscore{}>>\AgdaUnderscore{}}}\AgdaSpace{}%
  20. \AgdaSymbol{:}\AgdaSpace{}%
  21. \AgdaPrimitive{Set}\AgdaSpace{}%
  22. \AgdaKeyword{where}\<%
  23. \\
  24. \>[0]\AgdaKeyword{data}\AgdaSpace{}%
  25. \AgdaOperator{\AgdaDatatype{\AgdaUnderscore{}<<\AgdaUnderscore{}}}\AgdaSpace{}%
  26. \AgdaSymbol{:}\AgdaSpace{}%
  27. \AgdaPrimitive{Set}\AgdaSpace{}%
  28. \AgdaKeyword{where}\<%
  29. \\
  30. \>[0]\<%
  31. \end{code}
  32. Let's try some infix declaration with surrounding text.
  33. \begin{code}%
  34. \>[0]\AgdaKeyword{module}\AgdaSpace{}%
  35. \AgdaModule{SurroundingText}\AgdaSpace{}%
  36. \AgdaKeyword{where}\<%
  37. \\
  38. \>[0]\<%
  39. \end{code}
  40. In the following, we declare the fixity of two operators.
  41. \begin{code}%
  42. \>[0][@{}l@{\AgdaIndent{1}}]%
  43. \>[2]\AgdaKeyword{infix}\AgdaSpace{}%
  44. \AgdaNumber{5}\AgdaSpace{}%
  45. \AgdaOperator{\AgdaPostulate{\AgdaUnderscore{}+\AgdaUnderscore{}}}\AgdaSpace{}%
  46. \AgdaOperator{\AgdaPostulate{\AgdaUnderscore{}*\AgdaUnderscore{}}}\<%
  47. \end{code}
  48. A fixity declaration can precede the actual declaration of the names.
  49. \begin{code}%
  50. %
  51. \>[2]\AgdaKeyword{postulate}\AgdaSpace{}%
  52. \AgdaOperator{\AgdaPostulate{\AgdaUnderscore{}+\AgdaUnderscore{}}}\AgdaSpace{}%
  53. \AgdaOperator{\AgdaPostulate{\AgdaUnderscore{}*\AgdaUnderscore{}}}\AgdaSpace{}%
  54. \AgdaSymbol{:}\AgdaSpace{}%
  55. \AgdaPrimitive{Set}\<%
  56. \end{code}
  57. Fixity declarations can also occur when renaming during import.
  58. \begin{code}%
  59. \>[0]\AgdaKeyword{open}\AgdaSpace{}%
  60. \AgdaModule{SurroundingText}\AgdaSpace{}%
  61. \AgdaKeyword{renaming}\AgdaSpace{}%
  62. \AgdaSymbol{(}\AgdaOperator{\AgdaPostulate{\AgdaUnderscore{}+\AgdaUnderscore{}}}\AgdaSpace{}%
  63. \AgdaSymbol{to}\AgdaSpace{}%
  64. \AgdaKeyword{infixl}\AgdaSpace{}%
  65. \AgdaNumber{5}\AgdaSpace{}%
  66. \AgdaOperator{\AgdaPostulate{\AgdaUnderscore{}+\AgdaUnderscore{}}}\AgdaSymbol{;}%
  67. \>[53]\AgdaOperator{\AgdaPostulate{\AgdaUnderscore{}*\AgdaUnderscore{}}}\AgdaSpace{}%
  68. \AgdaSymbol{to}\AgdaSpace{}%
  69. \AgdaKeyword{infixl}\AgdaSpace{}%
  70. \AgdaNumber{10}\AgdaSpace{}%
  71. \AgdaOperator{\AgdaPostulate{\AgdaUnderscore{}\&\AgdaUnderscore{}}}\AgdaSymbol{)}\<%
  72. \end{code}
  73. \end{document}