[project @ 1999-09-17 11:22:53 by sof]
authorsof <unknown>
Fri, 17 Sep 1999 11:22:53 +0000 (11:22 +0000)
committersof <unknown>
Fri, 17 Sep 1999 11:22:53 +0000 (11:22 +0000)
Fixed bogus Show instances for Maybe and Either

ghc/lib/std/PrelShow.lhs

index 42c6250..b09d74d 100644 (file)
@@ -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}