PreludeShow.agda 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. module PreludeShow where
  2. import RTP -- magic module
  3. import AlonzoPrelude as Prelude
  4. open import PreludeNat
  5. open import PreludeString
  6. import PreludeList
  7. open import PreludeBool
  8. open Prelude
  9. -- open Data.Integer, using (Int, pos, neg)
  10. open PreludeList hiding (_++_)
  11. showInt : Int -> String
  12. showInt = RTP.primShowInt
  13. showNat : Nat -> String
  14. showNat n = showInt (RTP.primNatToInt n)
  15. {-
  16. showNat : Nat -> String
  17. showNat zero = "0"
  18. showNat n = reverseString $ show n
  19. where
  20. digit : Nat -> String
  21. digit 0 = "0"
  22. digit 1 = "1"
  23. digit 2 = "2"
  24. digit 3 = "3"
  25. digit 4 = "4"
  26. digit 5 = "5"
  27. digit 6 = "6"
  28. digit 7 = "7"
  29. digit 8 = "8"
  30. digit 9 = "9"
  31. digit _ = "?"
  32. show : Nat -> String
  33. show zero = ""
  34. show n = digit (mod n 10) ++ show (div n 10)
  35. -}
  36. {-
  37. showInt : Int -> String
  38. showInt (pos n) = showNat n
  39. showInt (neg n) = "-" ++ showNat (suc n)
  40. -}
  41. showChar : Char -> String
  42. showChar = RTP.primShowChar
  43. showBool : Bool -> String
  44. showBool true = "true"
  45. showBool false = "false"
  46. primitive
  47. primShowFloat : Float -> String
  48. showFloat : Float -> String
  49. showFloat = primShowFloat