@@ -91,19 +91,22 @@ showCon d conName shownArgs = showParens (d >= App) $ conName ++ shownArgs
9191showArg : Show a => (x : a) -> String
9292showArg x = " " ++ showPrec App x
9393
94+firstCharIs : (Char -> Bool) -> String -> Bool
95+firstCharIs p s with (strM s)
96+ firstCharIs p "" | StrNil = False
97+ firstCharIs p (strCons c cs) | StrCons c cs = p c
98+
99+primNumShow : (a -> String) -> Prec -> a -> String
100+primNumShow f d x = let str = f x in showParens (d >= PrefixMinus && firstCharIs (== '-') str) str
101+
94102instance Show Int where
95− show = prim__toStrInt
103+ showPrec = primNumShow prim__toStrInt
96104
97105instance Show Integer where
98− show = prim__toStrBigInt
106+ showPrec = primNumShow prim__toStrBigInt
99107
100108instance Show Double where
101− show = prim__floatToStr
102−
103−firstCharIs : (Char -> Bool) -> String -> Bool
104−firstCharIs p s with (strM s)
105− firstCharIs p "" | StrNil = False
106− firstCharIs p (strCons c cs) | StrCons c cs = p c
109+ showPrec = primNumShow prim__floatToStr
107110
108111protectEsc : (Char -> Bool) -> String -> String -> String
109112protectEsc p f s = f ++ (if firstCharIs p s then "\\&" else "") ++ s