From bf53dff25f17bfad80b7ac775e5d6c52c125247b Mon Sep 17 00:00:00 2001 From: sof Date: Fri, 17 Sep 1999 11:22:53 +0000 Subject: [PATCH] [project @ 1999-09-17 11:22:53 by sof] Fixed bogus Show instances for Maybe and Either --- ghc/lib/std/PrelShow.lhs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/ghc/lib/std/PrelShow.lhs b/ghc/lib/std/PrelShow.lhs index 42c6250..b09d74d 100644 --- a/ghc/lib/std/PrelShow.lhs +++ b/ghc/lib/std/PrelShow.lhs @@ -104,13 +104,18 @@ instance Show Int where instance Show a => Show (Maybe a) where showsPrec _p Nothing = showString "Nothing" - showsPrec _p (Just x) = showString "Just " . shows x - -- Not sure I have the priorities right here + showsPrec p@(I# p#) (Just x) + = showParen (p# >=# 10#) $ + showString "Just " . + showsPrec (I# 10#) x instance (Show a, Show b) => Show (Either a b) where - showsPrec _p (Left a) = showString "Left " . shows a - showsPrec _p (Right b) = showString "Right " . shows b - -- Not sure I have the priorities right here + showsPrec p@(I# p#) e = + showParen (p# >=# 10#) $ + case e of + Left a -> showString "Left " . showsPrec (I# 10#) a + Right b -> showString "Right " . showsPrec (I# 10#) b + \end{code} -- 1.7.10.4