VaryingClauseArity.agda 549 B

1234567891011121314151617181920212223242526272829
  1. module VaryingClauseArity where
  2. -- see also thread https://lists.chalmers.se/pipermail/agda-dev/2015-January/000041.html
  3. open import Common.IO
  4. open import Common.Unit
  5. open import Common.Nat
  6. Sum : Nat → Set
  7. Sum 0 = Nat
  8. Sum (suc n) = Nat → Sum n
  9. sum : (acc : Nat) (n : Nat) → Sum n
  10. sum acc 0 = acc
  11. sum acc (suc n) 0 = sum acc n
  12. sum acc (suc n) m = sum (m + acc) n
  13. -- expected:
  14. -- 10
  15. -- 20
  16. -- 33
  17. main : IO Unit
  18. main = printNat (sum 10 0) ,,
  19. putStr "\n" ,,
  20. printNat (sum 20 1 0) ,,
  21. putStr "\n" ,,
  22. printNat (sum 30 1 3)