CopatternRecord.agda 411 B

1234567891011121314151617181920212223242526272829303132333435
  1. {-# OPTIONS --copatterns #-}
  2. open import Common.Nat
  3. open import Common.IO
  4. open import Common.Unit
  5. record Test : Set where
  6. field
  7. a b c : Nat
  8. f : Test -> Nat
  9. f r = a + b + c
  10. where open Test r
  11. open Test
  12. r1 : Test
  13. a r1 = 100
  14. b r1 = 120
  15. c r1 = 140
  16. r2 : Test
  17. c r2 = 400
  18. a r2 = 200
  19. b r2 = 300
  20. g : Nat
  21. g = f r1 + a m + b m + c m
  22. where m = r2
  23. main : IO Unit
  24. main = printNat g
  25. -- Expected Output: 1260