records 978 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. What do we want?
  2. ────────────────
  3. ∙ declaration syntax
  4. record Point : Set where
  5. x : Nat
  6. y : Nat
  7. ∙ constructor
  8. record { x = 4; y = 2 }
  9. ∙ projection functions
  10. dist = x p ^ 2 + y p ^ 2
  11. ∙ open
  12. open module P = Point p
  13. dist = sqrt (x ^ 2 + y ^ 2)
  14. ∙ η
  15. p ≡ record { x = x p; y = y p }
  16. ∙ pattern matching
  17. f (record { x = suc n }) = n
  18. ∙ record update syntax
  19. how?
  20. record p { x = zero } ?
  21. Schedule
  22. ────────
  23. First
  24. ∙ declaration systax
  25. ∙ constructor
  26. ∙ projection functions
  27. ∙ open
  28. Next
  29. ∙ η
  30. Later
  31. ∙ pattern matching
  32. ∙ update syntax
  33. What does it mean?
  34. ──────────────────
  35. data Point : Set where
  36. <Point> : (x : Nat)(y : Nat) -> Point
  37. module Point (p : Point) where
  38. x : Nat
  39. x = <magic>
  40. y : Nat
  41. y = <magic>
  42. Issues
  43. ──────
  44. ∙ mutual records? yes
  45. will it be a problem? probably not