X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=GHC%2FShow.lhs;h=dc19d8741a61cee33cfe7a816fc437f2810cd3f9;hb=397c8d868b884a37446acfa788c12d48a077ef94;hp=30858da226769e79321cd52b9e3acfce20904e66;hpb=ad2f35188663652eca67184e744419478ac4b601;p=ghc-base.git diff --git a/GHC/Show.lhs b/GHC/Show.lhs index 30858da..dc19d87 100644 --- a/GHC/Show.lhs +++ b/GHC/Show.lhs @@ -1,5 +1,5 @@ \begin{code} -{-# OPTIONS_GHC -fno-implicit-prelude #-} +{-# OPTIONS_GHC -XNoImplicitPrelude #-} {-# OPTIONS_HADDOCK hide #-} ----------------------------------------------------------------------------- -- | @@ -35,12 +35,7 @@ module GHC.Show import GHC.Base import Data.Maybe -import Data.Either -import GHC.List ( (!!), foldr1 -#ifdef USE_REPORT_PRELUDE - , concatMap -#endif - ) +import GHC.List ((!!), foldr1) \end{code} @@ -203,14 +198,6 @@ instance Show a => Show (Maybe a) where = (showParen (p > appPrec) $ showString "Just " . showsPrec appPrec1 x) s - -instance (Show a, Show b) => Show (Either a b) where - showsPrec p e s = - (showParen (p > appPrec) $ - case e of - Left a -> showString "Left " . showsPrec appPrec1 a - Right b -> showString "Right " . showsPrec appPrec1 b) - s \end{code} @@ -360,6 +347,7 @@ showLitChar c s = showString ('\\' : asciiTab!!ord c) s -- I've done manual eta-expansion here, becuase otherwise it's -- impossible to stop (asciiTab!!ord) getting floated out as an MFE +isDec :: Char -> Bool isDec c = c >= '0' && c <= '9' protectEsc :: (Char -> Bool) -> ShowS -> ShowS @@ -389,6 +377,7 @@ intToDigit (I# i) | i >=# 10# && i <=# 15# = unsafeChr (ord 'a' `minusInt` ten `plusInt` I# i) | otherwise = error ("Char.intToDigit: not a digit " ++ show (I# i)) +ten :: Int ten = I# 10# showSignedInt :: Int -> Int -> ShowS @@ -399,7 +388,7 @@ showSignedInt (I# p) (I# n) r itos :: Int# -> String -> String itos n# cs | n# <# 0# = - let I# minInt# = minInt in + let !(I# minInt#) = minInt in if n# ==# minInt# -- negateInt# minInt overflows, so we can't do that: then '-' : itos' (negateInt# (n# `quotInt#` 10#)) @@ -408,8 +397,8 @@ itos n# cs | otherwise = itos' n# cs where itos' :: Int# -> String -> String - itos' n# cs - | n# <# 10# = C# (chr# (ord# '0'# +# n#)) : cs - | otherwise = case chr# (ord# '0'# +# (n# `remInt#` 10#)) of { c# -> - itos' (n# `quotInt#` 10#) (C# c# : cs) } + itos' x# cs' + | x# <# 10# = C# (chr# (ord# '0'# +# x#)) : cs' + | otherwise = case chr# (ord# '0'# +# (x# `remInt#` 10#)) of { c# -> + itos' (x# `quotInt#` 10#) (C# c# : cs') } \end{code}