Links.lagda 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. \documentclass{article}
  2. \usepackage{hyperref}
  3. \usepackage[links]{agda}
  4. \begin{document}
  5. \AgdaTarget{ℕ}
  6. \AgdaTarget{zero}
  7. \begin{code}
  8. data ℕ : Set where
  9. zero : ℕ
  10. suc : ℕ → ℕ
  11. \end{code}
  12. See next page for how to define \AgdaFunction{two} (doesn't turn into a
  13. link because the target hasn't been defined yet). We could do it
  14. manually though; \hyperlink{two}{\AgdaDatatype{two}}.
  15. \newpage
  16. \AgdaTarget{two}
  17. \hypertarget{two}{}
  18. \begin{code}
  19. two : ℕ
  20. two = suc (suc zero)
  21. \end{code}
  22. \AgdaInductiveConstructor{zero} is of type
  23. \AgdaDatatype{ℕ}. \AgdaInductiveConstructor{suc} has not been defined to
  24. be a target so it doesn't turn into a link.
  25. \newpage
  26. Now that the target for \AgdaFunction{two} has been defined the link
  27. works automatically.
  28. \begin{code}
  29. data Bool : Set where
  30. true false : Bool
  31. \end{code}
  32. The AgdaTarget command takes a list as input, enabling several targets
  33. to be specified as follows:
  34. \AgdaTarget{if, then, else, if\_then\_else\_}
  35. \begin{code}
  36. if_then_else_ : {A : Set} → Bool → A → A → A
  37. if true then t else f = t
  38. if false then t else f = f
  39. \end{code}
  40. \newpage
  41. Mixfix identifier need their underscores escaped:
  42. \AgdaFunction{if\_then\_else\_}.
  43. \end{document}