Remove showPrec, use show everywhere

This commit is contained in:
xenia 2023-09-03 12:25:28 +02:00
parent 989197d488
commit 5103fc0996
4 changed files with 13 additions and 14 deletions

View File

@ -72,24 +72,23 @@ instance
record Show (T : Type) : Type₁ where record Show (T : Type) : Type₁ where
field field
showPrec : T String.String
show : T String.String show : T String.String
show x = showPrec x 0
open Show ⦃...⦄ public open Show ⦃...⦄ public
instance instance
open import Data.Nat.Show using () renaming (show to show-) open import Data.Nat.Show using () renaming (show to show-)
ShowNat : Show ShowNat : Show
ShowNat .showPrec x _ = show- x ShowNat .show x = show- x
ShowString : Show String.String ShowString : Show String.String
ShowString .showPrec x _ = String.show x ShowString .show x = String.show x
ShowList : {A : Type} Show A Show (List A) ShowList : {A : Type} Show A Show (List A)
ShowList {A} .showPrec x _ = "[" String.++ go x String.++ "]" ShowList {A} .show x = "[" String.++ go x String.++ "]"
where where
go : List A String.String go : List A String.String
go [] = "" go [] = ""
go (x []) = showPrec x 0 go (x []) = show x
go (x xs) = showPrec x 0 String.++ ", " String.++ go xs go (x xs) = show x String.++ ", " String.++ go xs

View File

@ -38,7 +38,7 @@ instance
EqByte ._==_ a b = a .value == b .value EqByte ._==_ a b = a .value == b .value
ShowByte : Show Byte ShowByte : Show Byte
ShowByte .showPrec x _ = "< " String.++ showPrec (x .value) 1 String.++ " >" ShowByte .show x = "< " String.++ show (x .value) String.++ " >"
where where
import Data.String as String import Data.String as String

View File

@ -25,6 +25,6 @@ list⁺-to-list (x ∷⁺ xs) = x ∷ list⁺-to-list xs
instance instance
ShowList⁺ : {A : Type} Show A Show (List⁺ A) ShowList⁺ : {A : Type} Show A Show (List⁺ A)
ShowList⁺ .showPrec x p = showPrec (list⁺-to-list x) p String.++ "" ShowList⁺ .show x = show (list⁺-to-list x) String.++ ""
where where
import Data.String as String import Data.String as String

View File

@ -29,7 +29,7 @@ data HTTP-Method : Type where
instance instance
ShowMethod : Show HTTP-Method ShowMethod : Show HTTP-Method
ShowMethod .showPrec x _ = go x ShowMethod .show x = go x
where where
go : HTTP-Method String.String go : HTTP-Method String.String
go GET = "GET" go GET = "GET"
@ -90,9 +90,9 @@ module Parse-URL where
instance instance
ShowPath : Show Path ShowPath : Show Path
ShowPath .showPrec $ _ = "(empty path)" ShowPath .show $ = "(empty path)"
ShowPath .showPrec (p / $) _ = p ShowPath .show (p / $) = p
ShowPath .showPrec (p / rest@(_ / _)) n = p String.++ "/" String.++ showPrec rest n ShowPath .show (p / rest@(_ / _)) = p String.++ "/" String.++ show rest
infixr 5 _/_ infixr 5 _/_