Links.quick.tex 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. \documentclass{article}
  2. \usepackage{hyperref}
  3. \usepackage[links]{agda}
  4. \begin{document}
  5. \AgdaTarget{ℕ}
  6. \AgdaTarget{zero}
  7. \begin{code}%
  8. \>[0]\AgdaKeyword{data}\AgdaSpace{}%
  9. \AgdaDatatype{ℕ}\AgdaSpace{}%
  10. \AgdaSymbol{:}\AgdaSpace{}%
  11. \AgdaPrimitive{Set}\AgdaSpace{}%
  12. \AgdaKeyword{where}\<%
  13. \\
  14. \>[0][@{}l@{\AgdaIndent{0}}]%
  15. \>[2]\AgdaInductiveConstructor{zero}%
  16. \>[8]\AgdaSymbol{:}\AgdaSpace{}%
  17. \AgdaDatatype{ℕ}\<%
  18. \\
  19. %
  20. \>[2]\AgdaInductiveConstructor{suc}%
  21. \>[8]\AgdaSymbol{:}\AgdaSpace{}%
  22. \AgdaDatatype{ℕ}\AgdaSpace{}%
  23. \AgdaSymbol{→}\AgdaSpace{}%
  24. \AgdaDatatype{ℕ}\<%
  25. \end{code}
  26. See next page for how to define \AgdaFunction{two} (doesn't turn into a
  27. link because the target hasn't been defined yet). We could do it
  28. manually though; \hyperlink{two}{\AgdaDatatype{two}}.
  29. \newpage
  30. \AgdaTarget{two}
  31. \hypertarget{two}{}
  32. \begin{code}%
  33. \>[0]\AgdaFunction{two}\AgdaSpace{}%
  34. \AgdaSymbol{:}\AgdaSpace{}%
  35. \AgdaDatatype{ℕ}\<%
  36. \\
  37. \>[0]\AgdaFunction{two}\AgdaSpace{}%
  38. \AgdaSymbol{=}\AgdaSpace{}%
  39. \AgdaInductiveConstructor{suc}\AgdaSpace{}%
  40. \AgdaSymbol{(}\AgdaInductiveConstructor{suc}\AgdaSpace{}%
  41. \AgdaInductiveConstructor{zero}\AgdaSymbol{)}\<%
  42. \end{code}
  43. \AgdaInductiveConstructor{zero} is of type
  44. \AgdaDatatype{ℕ}. \AgdaInductiveConstructor{suc} has not been defined to
  45. be a target so it doesn't turn into a link.
  46. \newpage
  47. Now that the target for \AgdaFunction{two} has been defined the link
  48. works automatically.
  49. \begin{code}%
  50. \>[0]\AgdaKeyword{data}\AgdaSpace{}%
  51. \AgdaDatatype{Bool}\AgdaSpace{}%
  52. \AgdaSymbol{:}\AgdaSpace{}%
  53. \AgdaPrimitive{Set}\AgdaSpace{}%
  54. \AgdaKeyword{where}\<%
  55. \\
  56. \>[0][@{}l@{\AgdaIndent{0}}]%
  57. \>[2]\AgdaInductiveConstructor{true}\AgdaSpace{}%
  58. \AgdaInductiveConstructor{false}\AgdaSpace{}%
  59. \AgdaSymbol{:}\AgdaSpace{}%
  60. \AgdaDatatype{Bool}\<%
  61. \end{code}
  62. The AgdaTarget command takes a list as input, enabling several targets
  63. to be specified as follows:
  64. \AgdaTarget{if, then, else, if\_then\_else\_}
  65. \begin{code}%
  66. \>[0]\AgdaOperator{\AgdaFunction{if\AgdaUnderscore{}then\AgdaUnderscore{}else\AgdaUnderscore{}}}\AgdaSpace{}%
  67. \AgdaSymbol{:}\AgdaSpace{}%
  68. \AgdaSymbol{\{}\AgdaBound{A}\AgdaSpace{}%
  69. \AgdaSymbol{:}\AgdaSpace{}%
  70. \AgdaPrimitive{Set}\AgdaSymbol{\}}\AgdaSpace{}%
  71. \AgdaSymbol{→}\AgdaSpace{}%
  72. \AgdaDatatype{Bool}\AgdaSpace{}%
  73. \AgdaSymbol{→}\AgdaSpace{}%
  74. \AgdaBound{A}\AgdaSpace{}%
  75. \AgdaSymbol{→}\AgdaSpace{}%
  76. \AgdaBound{A}\AgdaSpace{}%
  77. \AgdaSymbol{→}\AgdaSpace{}%
  78. \AgdaBound{A}\<%
  79. \\
  80. \>[0]\AgdaOperator{\AgdaFunction{if}}\AgdaSpace{}%
  81. \AgdaInductiveConstructor{true}\AgdaSpace{}%
  82. \AgdaOperator{\AgdaFunction{then}}\AgdaSpace{}%
  83. \AgdaBound{t}\AgdaSpace{}%
  84. \AgdaOperator{\AgdaFunction{else}}\AgdaSpace{}%
  85. \AgdaBound{f}\AgdaSpace{}%
  86. \AgdaSymbol{=}\AgdaSpace{}%
  87. \AgdaBound{t}\<%
  88. \\
  89. \>[0]\AgdaOperator{\AgdaFunction{if}}\AgdaSpace{}%
  90. \AgdaInductiveConstructor{false}\AgdaSpace{}%
  91. \AgdaOperator{\AgdaFunction{then}}\AgdaSpace{}%
  92. \AgdaBound{t}\AgdaSpace{}%
  93. \AgdaOperator{\AgdaFunction{else}}\AgdaSpace{}%
  94. \AgdaBound{f}\AgdaSpace{}%
  95. \AgdaSymbol{=}\AgdaSpace{}%
  96. \AgdaBound{f}\<%
  97. \end{code}
  98. \newpage
  99. Mixfix identifier need their underscores escaped:
  100. \AgdaFunction{if\_then\_else\_}.
  101. \end{document}