Mutual.agda 734 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. module Mutual where
  2. open import Common.IO
  3. open import Common.String
  4. open import Common.Unit
  5. mutual
  6. data G : Set where
  7. GA : {g : G}(f : F g) -> G
  8. GB : G
  9. data F : G -> Set where
  10. FA : (g : G) -> F g
  11. FB : F GB
  12. mutual
  13. incG : G -> G
  14. incG GB = GA FB
  15. incG (GA f) = GA (incF f)
  16. incF : {g : G} -> F g -> F (incG g)
  17. incF FB = FA (GA FB)
  18. incF (FA g) = FA (incG g)
  19. mutual
  20. PrintF : {g : G} -> F g -> String
  21. PrintF FB = "FB"
  22. PrintF (FA g) = "(FA " +S+ PrintG g +S+ ")"
  23. PrintG : G -> String
  24. PrintG GB = "GB"
  25. PrintG (GA f) = "(GA " +S+ PrintF f +S+ ")"
  26. main : IO Unit
  27. main =
  28. putStrLn (PrintF (FA (GA (FA GB)))) ,,
  29. putStrLn (PrintG (incG (GA (incF FB)))) ,, --
  30. return unit