{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE CPP, NoImplicitPrelude, BangPatterns, StandaloneDeriving,
             MagicHash, UnboxedTuples #-}
{-# OPTIONS_HADDOCK not-home #-}

#include "MachDeps.h"
#if SIZEOF_HSWORD == 4
#define DIGITS       9
#define BASE         1000000000
#elif SIZEOF_HSWORD == 8
#define DIGITS       18
#define BASE         1000000000000000000
#else
#error Please define DIGITS and BASE
-- DIGITS should be the largest integer such that
--     10^DIGITS < 2^(SIZEOF_HSWORD * 8 - 1)
-- BASE should be 10^DIGITS. Note that ^ is not available yet.
#endif

-----------------------------------------------------------------------------
-- |
-- Module      :  GHC.Show
-- Copyright   :  (c) The University of Glasgow, 1992-2002
-- License     :  see libraries/base/LICENSE
--
-- Maintainer  :  cvs-ghc@haskell.org
-- Stability   :  internal
-- Portability :  non-portable (GHC Extensions)
--
-- The 'Show' class, and related operations.
--
-----------------------------------------------------------------------------

module GHC.Show
        (
        Show(..), ShowS,

        -- Instances for Show: (), [], Bool, Ordering, Int, Char

        -- Show support code
        shows, showChar, showString, showMultiLineString,
        showParen, showList__, showCommaSpace, showSpace,
        showLitChar, showLitString, protectEsc,
        intToDigit, showSignedInt,
        appPrec, appPrec1,

        -- Character operations
        asciiTab,
  )
        where

import GHC.Base
import GHC.List ((!!), foldr1, break)
import GHC.Num
import GHC.Stack.Types


-- | The @shows@ functions return a function that prepends the
-- output 'String' to an existing 'String'.  This allows constant-time
-- concatenation of results using function composition.
type ShowS = String -> String

-- | Conversion of values to readable 'String's.
--
-- Derived instances of 'Show' have the following properties, which
-- are compatible with derived instances of 'Text.Read.Read':
--
-- * The result of 'show' is a syntactically correct Haskell
--   expression containing only constants, given the fixity
--   declarations in force at the point where the type is declared.
--   It contains only the constructor names defined in the data type,
--   parentheses, and spaces.  When labelled constructor fields are
--   used, braces, commas, field names, and equal signs are also used.
--
-- * If the constructor is defined to be an infix operator, then
--   'showsPrec' will produce infix applications of the constructor.
--
-- * the representation will be enclosed in parentheses if the
--   precedence of the top-level constructor in @x@ is less than @d@
--   (associativity is ignored).  Thus, if @d@ is @0@ then the result
--   is never surrounded in parentheses; if @d@ is @11@ it is always
--   surrounded in parentheses, unless it is an atomic expression.
--
-- * If the constructor is defined using record syntax, then 'show'
--   will produce the record-syntax form, with the fields given in the
--   same order as the original declaration.
--
-- For example, given the declarations
--
-- > infixr 5 :^:
-- > data Tree a =  Leaf a  |  Tree a :^: Tree a
--
-- the derived instance of 'Show' is equivalent to
--
-- > instance (Show a) => Show (Tree a) where
-- >
-- >        showsPrec d (Leaf m) = showParen (d > app_prec) $
-- >             showString "Leaf " . showsPrec (app_prec+1) m
-- >          where app_prec = 10
-- >
-- >        showsPrec d (u :^: v) = showParen (d > up_prec) $
-- >             showsPrec (up_prec+1) u .
-- >             showString " :^: "      .
-- >             showsPrec (up_prec+1) v
-- >          where up_prec = 5
--
-- Note that right-associativity of @:^:@ is ignored.  For example,
--
-- * @'show' (Leaf 1 :^: Leaf 2 :^: Leaf 3)@ produces the string
--   @\"Leaf 1 :^: (Leaf 2 :^: Leaf 3)\"@.

class  Show a  where
    {-# MINIMAL showsPrec | show #-}

    -- | Convert a value to a readable 'String'.
    --
    -- 'showsPrec' should satisfy the law
    --
    -- > showsPrec d x r ++ s  ==  showsPrec d x (r ++ s)
    --
    -- Derived instances of 'Text.Read.Read' and 'Show' satisfy the following:
    --
    -- * @(x,\"\")@ is an element of
    --   @('Text.Read.readsPrec' d ('showsPrec' d x \"\"))@.
    --
    -- That is, 'Text.Read.readsPrec' parses the string produced by
    -- 'showsPrec', and delivers the value that 'showsPrec' started with.

    showsPrec :: Int    -- ^ the operator precedence of the enclosing
                        -- context (a number from @0@ to @11@).
                        -- Function application has precedence @10@.
              -> a      -- ^ the value to be converted to a 'String'
              -> ShowS

    -- | A specialised variant of 'showsPrec', using precedence context
    -- zero, and returning an ordinary 'String'.
    show      :: a   -> String

    -- | The method 'showList' is provided to allow the programmer to
    -- give a specialised way of showing lists of values.
    -- For example, this is used by the predefined 'Show' instance of
    -- the 'Char' type, where values of type 'String' should be shown
    -- in double quotes, rather than between square brackets.
    showList  :: [a] -> ShowS

    showsPrec _ x :: a
x s :: String
s = a -> String
forall a. Show a => a -> String
show a
x String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
s
    show x :: a
x          = a -> ShowS
forall a. Show a => a -> ShowS
shows a
x ""
    showList ls :: [a]
ls   s :: String
s = (a -> ShowS) -> [a] -> ShowS
forall a. (a -> ShowS) -> [a] -> ShowS
showList__ a -> ShowS
forall a. Show a => a -> ShowS
shows [a]
ls String
s

showList__ :: (a -> ShowS) ->  [a] -> ShowS
showList__ :: (a -> ShowS) -> [a] -> ShowS
showList__ _     []     s :: String
s = "[]" String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
s
showList__ showx :: a -> ShowS
showx (x :: a
x:xs :: [a]
xs) s :: String
s = '[' Char -> ShowS
forall a. a -> [a] -> [a]
: a -> ShowS
showx a
x ([a] -> String
showl [a]
xs)
  where
    showl :: [a] -> String
showl []     = ']' Char -> ShowS
forall a. a -> [a] -> [a]
: String
s
    showl (y :: a
y:ys :: [a]
ys) = ',' Char -> ShowS
forall a. a -> [a] -> [a]
: a -> ShowS
showx a
y ([a] -> String
showl [a]
ys)

appPrec, appPrec1 :: Int
        -- Use unboxed stuff because we don't have overloaded numerics yet
appPrec :: Int
appPrec = Int# -> Int
I# 10#        -- Precedence of application:
                        --   one more than the maximum operator precedence of 9
appPrec1 :: Int
appPrec1 = Int# -> Int
I# 11#       -- appPrec + 1

--------------------------------------------------------------
-- Simple Instances
--------------------------------------------------------------

-- | @since 2.01
deriving instance Show ()

-- | @since 2.01
instance Show a => Show [a]  where
  {-# SPECIALISE instance Show [String] #-}
  {-# SPECIALISE instance Show [Char] #-}
  {-# SPECIALISE instance Show [Int] #-}
  showsPrec :: Int -> [a] -> ShowS
showsPrec _         = [a] -> ShowS
forall a. Show a => [a] -> ShowS
showList

-- | @since 2.01
deriving instance Show Bool

-- | @since 2.01
deriving instance Show Ordering

-- | @since 2.01
instance  Show Char  where
    showsPrec :: Int -> Char -> ShowS
showsPrec _ '\'' = String -> ShowS
showString "'\\''"
    showsPrec _ c :: Char
c    = Char -> ShowS
showChar '\'' ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> ShowS
showLitChar Char
c ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> ShowS
showChar '\''

    showList :: String -> ShowS
showList cs :: String
cs = Char -> ShowS
showChar '"' ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showLitString String
cs ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> ShowS
showChar '"'

-- | @since 2.01
instance Show Int where
    showsPrec :: Int -> Int -> ShowS
showsPrec = Int -> Int -> ShowS
showSignedInt

-- | @since 2.01
instance Show Word where
    showsPrec :: Int -> Word -> ShowS
showsPrec _ (W# w :: Word#
w) = Word# -> ShowS
showWord Word#
w

showWord :: Word# -> ShowS
showWord :: Word# -> ShowS
showWord w# :: Word#
w# cs :: String
cs
 | Int# -> Bool
isTrue# (Word#
w# Word# -> Word# -> Int#
`ltWord#` 10##) = Char# -> Char
C# (Int# -> Char#
chr# (Char# -> Int#
ord# '0'# Int# -> Int# -> Int#
+# Word# -> Int#
word2Int# Word#
w#)) Char -> ShowS
forall a. a -> [a] -> [a]
: String
cs
 | Bool
otherwise = case Int# -> Char#
chr# (Char# -> Int#
ord# '0'# Int# -> Int# -> Int#
+# Word# -> Int#
word2Int# (Word#
w# Word# -> Word# -> Word#
`remWord#` 10##)) of
               c# :: Char#
c# ->
                   Word# -> ShowS
showWord (Word#
w# Word# -> Word# -> Word#
`quotWord#` 10##) (Char# -> Char
C# Char#
c# Char -> ShowS
forall a. a -> [a] -> [a]
: String
cs)

-- | @since 2.01
deriving instance Show a => Show (Maybe a)

-- | @since 4.11.0.0
deriving instance Show a => Show (NonEmpty a)

-- | @since 2.01
instance Show TyCon where
  showsPrec :: Int -> TyCon -> ShowS
showsPrec p :: Int
p (TyCon _ _ _ tc_name :: TrName
tc_name _ _) = Int -> TrName -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
p TrName
tc_name

-- | @since 4.9.0.0
instance Show TrName where
  showsPrec :: Int -> TrName -> ShowS
showsPrec _ (TrNameS s :: Addr#
s) = String -> ShowS
showString (Addr# -> String
unpackCStringUtf8# Addr#
s)
  showsPrec _ (TrNameD s :: String
s) = String -> ShowS
showString String
s

-- | @since 4.9.0.0
instance Show Module where
  showsPrec :: Int -> Module -> ShowS
showsPrec _ (Module p :: TrName
p m :: TrName
m) = TrName -> ShowS
forall a. Show a => a -> ShowS
shows TrName
p ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (':' Char -> ShowS
forall a. a -> [a] -> [a]
:) ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TrName -> ShowS
forall a. Show a => a -> ShowS
shows TrName
m

-- | @since 4.9.0.0
instance Show CallStack where
  showsPrec :: Int -> CallStack -> ShowS
showsPrec _ = [(String, SrcLoc)] -> ShowS
forall a. Show a => a -> ShowS
shows ([(String, SrcLoc)] -> ShowS)
-> (CallStack -> [(String, SrcLoc)]) -> CallStack -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CallStack -> [(String, SrcLoc)]
getCallStack

-- | @since 4.9.0.0
deriving instance Show SrcLoc

--------------------------------------------------------------
-- Show instances for the first few tuple
--------------------------------------------------------------

-- The explicit 's' parameters are important
-- Otherwise GHC thinks that "shows x" might take a lot of work to compute
-- and generates defns like
--      showsPrec _ (x,y) = let sx = shows x; sy = shows y in
--                          \s -> showChar '(' (sx (showChar ',' (sy (showChar ')' s))))

-- | @since 2.01
instance  (Show a, Show b) => Show (a,b)  where
  showsPrec :: Int -> (a, b) -> ShowS
showsPrec _ (a :: a
a,b :: b
b) s :: String
s = [ShowS] -> ShowS
show_tuple [a -> ShowS
forall a. Show a => a -> ShowS
shows a
a, b -> ShowS
forall a. Show a => a -> ShowS
shows b
b] String
s

-- | @since 2.01
instance (Show a, Show b, Show c) => Show (a, b, c) where
  showsPrec :: Int -> (a, b, c) -> ShowS
showsPrec _ (a :: a
a,b :: b
b,c :: c
c) s :: String
s = [ShowS] -> ShowS
show_tuple [a -> ShowS
forall a. Show a => a -> ShowS
shows a
a, b -> ShowS
forall a. Show a => a -> ShowS
shows b
b, c -> ShowS
forall a. Show a => a -> ShowS
shows c
c] String
s

-- | @since 2.01
instance (Show a, Show b, Show c, Show d) => Show (a, b, c, d) where
  showsPrec :: Int -> (a, b, c, d) -> ShowS
showsPrec _ (a :: a
a,b :: b
b,c :: c
c,d :: d
d) s :: String
s = [ShowS] -> ShowS
show_tuple [a -> ShowS
forall a. Show a => a -> ShowS
shows a
a, b -> ShowS
forall a. Show a => a -> ShowS
shows b
b, c -> ShowS
forall a. Show a => a -> ShowS
shows c
c, d -> ShowS
forall a. Show a => a -> ShowS
shows d
d] String
s

-- | @since 2.01
instance (Show a, Show b, Show c, Show d, Show e) => Show (a, b, c, d, e) where
  showsPrec :: Int -> (a, b, c, d, e) -> ShowS
showsPrec _ (a :: a
a,b :: b
b,c :: c
c,d :: d
d,e :: e
e) s :: String
s = [ShowS] -> ShowS
show_tuple [a -> ShowS
forall a. Show a => a -> ShowS
shows a
a, b -> ShowS
forall a. Show a => a -> ShowS
shows b
b, c -> ShowS
forall a. Show a => a -> ShowS
shows c
c, d -> ShowS
forall a. Show a => a -> ShowS
shows d
d, e -> ShowS
forall a. Show a => a -> ShowS
shows e
e] String
s

-- | @since 2.01
instance (Show a, Show b, Show c, Show d, Show e, Show f) => Show (a,b,c,d,e,f) where
  showsPrec :: Int -> (a, b, c, d, e, f) -> ShowS
showsPrec _ (a :: a
a,b :: b
b,c :: c
c,d :: d
d,e :: e
e,f :: f
f) s :: String
s = [ShowS] -> ShowS
show_tuple [a -> ShowS
forall a. Show a => a -> ShowS
shows a
a, b -> ShowS
forall a. Show a => a -> ShowS
shows b
b, c -> ShowS
forall a. Show a => a -> ShowS
shows c
c, d -> ShowS
forall a. Show a => a -> ShowS
shows d
d, e -> ShowS
forall a. Show a => a -> ShowS
shows e
e, f -> ShowS
forall a. Show a => a -> ShowS
shows f
f] String
s

-- | @since 2.01
instance (Show a, Show b, Show c, Show d, Show e, Show f, Show g)
        => Show (a,b,c,d,e,f,g) where
  showsPrec :: Int -> (a, b, c, d, e, f, g) -> ShowS
showsPrec _ (a :: a
a,b :: b
b,c :: c
c,d :: d
d,e :: e
e,f :: f
f,g :: g
g) s :: String
s
        = [ShowS] -> ShowS
show_tuple [a -> ShowS
forall a. Show a => a -> ShowS
shows a
a, b -> ShowS
forall a. Show a => a -> ShowS
shows b
b, c -> ShowS
forall a. Show a => a -> ShowS
shows c
c, d -> ShowS
forall a. Show a => a -> ShowS
shows d
d, e -> ShowS
forall a. Show a => a -> ShowS
shows e
e, f -> ShowS
forall a. Show a => a -> ShowS
shows f
f, g -> ShowS
forall a. Show a => a -> ShowS
shows g
g] String
s

-- | @since 2.01
instance (Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h)
         => Show (a,b,c,d,e,f,g,h) where
  showsPrec :: Int -> (a, b, c, d, e, f, g, h) -> ShowS
showsPrec _ (a :: a
a,b :: b
b,c :: c
c,d :: d
d,e :: e
e,f :: f
f,g :: g
g,h :: h
h) s :: String
s
        = [ShowS] -> ShowS
show_tuple [a -> ShowS
forall a. Show a => a -> ShowS
shows a
a, b -> ShowS
forall a. Show a => a -> ShowS
shows b
b, c -> ShowS
forall a. Show a => a -> ShowS
shows c
c, d -> ShowS
forall a. Show a => a -> ShowS
shows d
d, e -> ShowS
forall a. Show a => a -> ShowS
shows e
e, f -> ShowS
forall a. Show a => a -> ShowS
shows f
f, g -> ShowS
forall a. Show a => a -> ShowS
shows g
g, h -> ShowS
forall a. Show a => a -> ShowS
shows h
h] String
s

-- | @since 2.01
instance (Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i)
         => Show (a,b,c,d,e,f,g,h,i) where
  showsPrec :: Int -> (a, b, c, d, e, f, g, h, i) -> ShowS
showsPrec _ (a :: a
a,b :: b
b,c :: c
c,d :: d
d,e :: e
e,f :: f
f,g :: g
g,h :: h
h,i :: i
i) s :: String
s
        = [ShowS] -> ShowS
show_tuple [a -> ShowS
forall a. Show a => a -> ShowS
shows a
a, b -> ShowS
forall a. Show a => a -> ShowS
shows b
b, c -> ShowS
forall a. Show a => a -> ShowS
shows c
c, d -> ShowS
forall a. Show a => a -> ShowS
shows d
d, e -> ShowS
forall a. Show a => a -> ShowS
shows e
e, f -> ShowS
forall a. Show a => a -> ShowS
shows f
f, g -> ShowS
forall a. Show a => a -> ShowS
shows g
g, h -> ShowS
forall a. Show a => a -> ShowS
shows h
h,
                      i -> ShowS
forall a. Show a => a -> ShowS
shows i
i] String
s

-- | @since 2.01
instance (Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i, Show j)
         => Show (a,b,c,d,e,f,g,h,i,j) where
  showsPrec :: Int -> (a, b, c, d, e, f, g, h, i, j) -> ShowS
showsPrec _ (a :: a
a,b :: b
b,c :: c
c,d :: d
d,e :: e
e,f :: f
f,g :: g
g,h :: h
h,i :: i
i,j :: j
j) s :: String
s
        = [ShowS] -> ShowS
show_tuple [a -> ShowS
forall a. Show a => a -> ShowS
shows a
a, b -> ShowS
forall a. Show a => a -> ShowS
shows b
b, c -> ShowS
forall a. Show a => a -> ShowS
shows c
c, d -> ShowS
forall a. Show a => a -> ShowS
shows d
d, e -> ShowS
forall a. Show a => a -> ShowS
shows e
e, f -> ShowS
forall a. Show a => a -> ShowS
shows f
f, g -> ShowS
forall a. Show a => a -> ShowS
shows g
g, h -> ShowS
forall a. Show a => a -> ShowS
shows h
h,
                      i -> ShowS
forall a. Show a => a -> ShowS
shows i
i, j -> ShowS
forall a. Show a => a -> ShowS
shows j
j] String
s

-- | @since 2.01
instance (Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i, Show j, Show k)
         => Show (a,b,c,d,e,f,g,h,i,j,k) where
  showsPrec :: Int -> (a, b, c, d, e, f, g, h, i, j, k) -> ShowS
showsPrec _ (a :: a
a,b :: b
b,c :: c
c,d :: d
d,e :: e
e,f :: f
f,g :: g
g,h :: h
h,i :: i
i,j :: j
j,k :: k
k) s :: String
s
        = [ShowS] -> ShowS
show_tuple [a -> ShowS
forall a. Show a => a -> ShowS
shows a
a, b -> ShowS
forall a. Show a => a -> ShowS
shows b
b, c -> ShowS
forall a. Show a => a -> ShowS
shows c
c, d -> ShowS
forall a. Show a => a -> ShowS
shows d
d, e -> ShowS
forall a. Show a => a -> ShowS
shows e
e, f -> ShowS
forall a. Show a => a -> ShowS
shows f
f, g -> ShowS
forall a. Show a => a -> ShowS
shows g
g, h -> ShowS
forall a. Show a => a -> ShowS
shows h
h,
                      i -> ShowS
forall a. Show a => a -> ShowS
shows i
i, j -> ShowS
forall a. Show a => a -> ShowS
shows j
j, k -> ShowS
forall a. Show a => a -> ShowS
shows k
k] String
s

-- | @since 2.01
instance (Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i, Show j, Show k,
          Show l)
         => Show (a,b,c,d,e,f,g,h,i,j,k,l) where
  showsPrec :: Int -> (a, b, c, d, e, f, g, h, i, j, k, l) -> ShowS
showsPrec _ (a :: a
a,b :: b
b,c :: c
c,d :: d
d,e :: e
e,f :: f
f,g :: g
g,h :: h
h,i :: i
i,j :: j
j,k :: k
k,l :: l
l) s :: String
s
        = [ShowS] -> ShowS
show_tuple [a -> ShowS
forall a. Show a => a -> ShowS
shows a
a, b -> ShowS
forall a. Show a => a -> ShowS
shows b
b, c -> ShowS
forall a. Show a => a -> ShowS
shows c
c, d -> ShowS
forall a. Show a => a -> ShowS
shows d
d, e -> ShowS
forall a. Show a => a -> ShowS
shows e
e, f -> ShowS
forall a. Show a => a -> ShowS
shows f
f, g -> ShowS
forall a. Show a => a -> ShowS
shows g
g, h -> ShowS
forall a. Show a => a -> ShowS
shows h
h,
                      i -> ShowS
forall a. Show a => a -> ShowS
shows i
i, j -> ShowS
forall a. Show a => a -> ShowS
shows j
j, k -> ShowS
forall a. Show a => a -> ShowS
shows k
k, l -> ShowS
forall a. Show a => a -> ShowS
shows l
l] String
s

-- | @since 2.01
instance (Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i, Show j, Show k,
          Show l, Show m)
         => Show (a,b,c,d,e,f,g,h,i,j,k,l,m) where
  showsPrec :: Int -> (a, b, c, d, e, f, g, h, i, j, k, l, m) -> ShowS
showsPrec _ (a :: a
a,b :: b
b,c :: c
c,d :: d
d,e :: e
e,f :: f
f,g :: g
g,h :: h
h,i :: i
i,j :: j
j,k :: k
k,l :: l
l,m :: m
m) s :: String
s
        = [ShowS] -> ShowS
show_tuple [a -> ShowS
forall a. Show a => a -> ShowS
shows a
a, b -> ShowS
forall a. Show a => a -> ShowS
shows b
b, c -> ShowS
forall a. Show a => a -> ShowS
shows c
c, d -> ShowS
forall a. Show a => a -> ShowS
shows d
d, e -> ShowS
forall a. Show a => a -> ShowS
shows e
e, f -> ShowS
forall a. Show a => a -> ShowS
shows f
f, g -> ShowS
forall a. Show a => a -> ShowS
shows g
g, h -> ShowS
forall a. Show a => a -> ShowS
shows h
h,
                      i -> ShowS
forall a. Show a => a -> ShowS
shows i
i, j -> ShowS
forall a. Show a => a -> ShowS
shows j
j, k -> ShowS
forall a. Show a => a -> ShowS
shows k
k, l -> ShowS
forall a. Show a => a -> ShowS
shows l
l, m -> ShowS
forall a. Show a => a -> ShowS
shows m
m] String
s

-- | @since 2.01
instance (Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i, Show j, Show k,
          Show l, Show m, Show n)
         => Show (a,b,c,d,e,f,g,h,i,j,k,l,m,n) where
  showsPrec :: Int -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> ShowS
showsPrec _ (a :: a
a,b :: b
b,c :: c
c,d :: d
d,e :: e
e,f :: f
f,g :: g
g,h :: h
h,i :: i
i,j :: j
j,k :: k
k,l :: l
l,m :: m
m,n :: n
n) s :: String
s
        = [ShowS] -> ShowS
show_tuple [a -> ShowS
forall a. Show a => a -> ShowS
shows a
a, b -> ShowS
forall a. Show a => a -> ShowS
shows b
b, c -> ShowS
forall a. Show a => a -> ShowS
shows c
c, d -> ShowS
forall a. Show a => a -> ShowS
shows d
d, e -> ShowS
forall a. Show a => a -> ShowS
shows e
e, f -> ShowS
forall a. Show a => a -> ShowS
shows f
f, g -> ShowS
forall a. Show a => a -> ShowS
shows g
g, h -> ShowS
forall a. Show a => a -> ShowS
shows h
h,
                      i -> ShowS
forall a. Show a => a -> ShowS
shows i
i, j -> ShowS
forall a. Show a => a -> ShowS
shows j
j, k -> ShowS
forall a. Show a => a -> ShowS
shows k
k, l -> ShowS
forall a. Show a => a -> ShowS
shows l
l, m -> ShowS
forall a. Show a => a -> ShowS
shows m
m, n -> ShowS
forall a. Show a => a -> ShowS
shows n
n] String
s

-- | @since 2.01
instance (Show a, Show b, Show c, Show d, Show e, Show f, Show g, Show h, Show i, Show j, Show k,
          Show l, Show m, Show n, Show o)
         => Show (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o) where
  showsPrec :: Int -> (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> ShowS
showsPrec _ (a :: a
a,b :: b
b,c :: c
c,d :: d
d,e :: e
e,f :: f
f,g :: g
g,h :: h
h,i :: i
i,j :: j
j,k :: k
k,l :: l
l,m :: m
m,n :: n
n,o :: o
o) s :: String
s
        = [ShowS] -> ShowS
show_tuple [a -> ShowS
forall a. Show a => a -> ShowS
shows a
a, b -> ShowS
forall a. Show a => a -> ShowS
shows b
b, c -> ShowS
forall a. Show a => a -> ShowS
shows c
c, d -> ShowS
forall a. Show a => a -> ShowS
shows d
d, e -> ShowS
forall a. Show a => a -> ShowS
shows e
e, f -> ShowS
forall a. Show a => a -> ShowS
shows f
f, g -> ShowS
forall a. Show a => a -> ShowS
shows g
g, h -> ShowS
forall a. Show a => a -> ShowS
shows h
h,
                      i -> ShowS
forall a. Show a => a -> ShowS
shows i
i, j -> ShowS
forall a. Show a => a -> ShowS
shows j
j, k -> ShowS
forall a. Show a => a -> ShowS
shows k
k, l -> ShowS
forall a. Show a => a -> ShowS
shows l
l, m -> ShowS
forall a. Show a => a -> ShowS
shows m
m, n -> ShowS
forall a. Show a => a -> ShowS
shows n
n, o -> ShowS
forall a. Show a => a -> ShowS
shows o
o] String
s

show_tuple :: [ShowS] -> ShowS
show_tuple :: [ShowS] -> ShowS
show_tuple ss :: [ShowS]
ss = Char -> ShowS
showChar '('
              ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ShowS -> ShowS -> ShowS) -> [ShowS] -> ShowS
forall a. (a -> a -> a) -> [a] -> a
foldr1 (\s :: ShowS
s r :: ShowS
r -> ShowS
s ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> ShowS
showChar ',' ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShowS
r) [ShowS]
ss
              ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> ShowS
showChar ')'

--------------------------------------------------------------
-- Support code for Show
--------------------------------------------------------------

-- | equivalent to 'showsPrec' with a precedence of 0.
shows           :: (Show a) => a -> ShowS
shows :: a -> ShowS
shows           =  Int -> a -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec 0

-- | utility function converting a 'Char' to a show function that
-- simply prepends the character unchanged.
showChar        :: Char -> ShowS
showChar :: Char -> ShowS
showChar        =  (:)

-- | utility function converting a 'String' to a show function that
-- simply prepends the string unchanged.
showString      :: String -> ShowS
showString :: String -> ShowS
showString      =  String -> ShowS
forall a. [a] -> [a] -> [a]
(++)

-- | utility function that surrounds the inner show function with
-- parentheses when the 'Bool' parameter is 'True'.
showParen       :: Bool -> ShowS -> ShowS
showParen :: Bool -> ShowS -> ShowS
showParen b :: Bool
b p :: ShowS
p   =  if Bool
b then Char -> ShowS
showChar '(' ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShowS
p ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> ShowS
showChar ')' else ShowS
p

showSpace :: ShowS
showSpace :: ShowS
showSpace = {-showChar ' '-} \ xs :: String
xs -> ' ' Char -> ShowS
forall a. a -> [a] -> [a]
: String
xs

showCommaSpace :: ShowS
showCommaSpace :: ShowS
showCommaSpace = String -> ShowS
showString ", "
-- Code specific for characters

-- | Convert a character to a string using only printable characters,
-- using Haskell source-language escape conventions.  For example:
--
-- > showLitChar '\n' s  =  "\\n" ++ s
--
showLitChar                :: Char -> ShowS
showLitChar :: Char -> ShowS
showLitChar c :: Char
c s :: String
s | Char
c Char -> Char -> Bool
forall a. Ord a => a -> a -> Bool
> '\DEL' =  Char -> ShowS
showChar '\\' ((Char -> Bool) -> ShowS -> ShowS
protectEsc Char -> Bool
isDec (Int -> ShowS
forall a. Show a => a -> ShowS
shows (Char -> Int
ord Char
c)) String
s)
showLitChar '\DEL'         s :: String
s =  String -> ShowS
showString "\\DEL" String
s
showLitChar '\\'           s :: String
s =  String -> ShowS
showString "\\\\" String
s
showLitChar c :: Char
c s :: String
s | Char
c Char -> Char -> Bool
forall a. Ord a => a -> a -> Bool
>= ' '   =  Char -> ShowS
showChar Char
c String
s
showLitChar '\a'           s :: String
s =  String -> ShowS
showString "\\a" String
s
showLitChar '\b'           s :: String
s =  String -> ShowS
showString "\\b" String
s
showLitChar '\f'           s :: String
s =  String -> ShowS
showString "\\f" String
s
showLitChar '\n'           s :: String
s =  String -> ShowS
showString "\\n" String
s
showLitChar '\r'           s :: String
s =  String -> ShowS
showString "\\r" String
s
showLitChar '\t'           s :: String
s =  String -> ShowS
showString "\\t" String
s
showLitChar '\v'           s :: String
s =  String -> ShowS
showString "\\v" String
s
showLitChar '\SO'          s :: String
s =  (Char -> Bool) -> ShowS -> ShowS
protectEsc (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== 'H') (String -> ShowS
showString "\\SO") String
s
showLitChar c :: Char
c              s :: String
s =  String -> ShowS
showString ('\\' Char -> ShowS
forall a. a -> [a] -> [a]
: [String]
asciiTab[String] -> Int -> String
forall a. [a] -> Int -> a
!!Char -> Int
ord Char
c) String
s
        -- I've done manual eta-expansion here, because otherwise it's
        -- impossible to stop (asciiTab!!ord) getting floated out as an MFE

showLitString :: String -> ShowS
-- | Same as 'showLitChar', but for strings
-- It converts the string to a string using Haskell escape conventions
-- for non-printable characters. Does not add double-quotes around the
-- whole thing; the caller should do that.
-- The main difference from showLitChar (apart from the fact that the
-- argument is a string not a list) is that we must escape double-quotes
showLitString :: String -> ShowS
showLitString []         s :: String
s = String
s
showLitString ('"' : cs :: String
cs) s :: String
s = String -> ShowS
showString "\\\"" (String -> ShowS
showLitString String
cs String
s)
showLitString (c :: Char
c   : cs :: String
cs) s :: String
s = Char -> ShowS
showLitChar Char
c (String -> ShowS
showLitString String
cs String
s)
   -- Making 's' an explicit parameter makes it clear to GHC that
   -- showLitString has arity 2, which avoids it allocating an extra lambda
   -- The sticking point is the recursive call to (showLitString cs), which
   -- it can't figure out would be ok with arity 2.

showMultiLineString :: String -> [String]
-- | Like 'showLitString' (expand escape characters using Haskell
-- escape conventions), but
--   * break the string into multiple lines
--   * wrap the entire thing in double quotes
-- Example:  @showMultiLineString "hello\ngoodbye\nblah"@
-- returns   @["\"hello\\n\\", "\\goodbye\n\\", "\\blah\""]@
showMultiLineString :: String -> [String]
showMultiLineString str :: String
str
  = Char -> String -> [String]
go '\"' String
str
  where
    go :: Char -> String -> [String]
go ch :: Char
ch s :: String
s = case (Char -> Bool) -> String -> (String, String)
forall a. (a -> Bool) -> [a] -> ([a], [a])
break (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== '\n') String
s of
                (l :: String
l, _:s' :: String
s'@(_:_)) -> (Char
ch Char -> ShowS
forall a. a -> [a] -> [a]
: String -> ShowS
showLitString String
l "\\n\\") String -> [String] -> [String]
forall a. a -> [a] -> [a]
: Char -> String -> [String]
go '\\' String
s'
                (l :: String
l, "\n")       -> [Char
ch Char -> ShowS
forall a. a -> [a] -> [a]
: String -> ShowS
showLitString String
l "\\n\""]
                (l :: String
l, _)          -> [Char
ch Char -> ShowS
forall a. a -> [a] -> [a]
: String -> ShowS
showLitString String
l "\""]

isDec :: Char -> Bool
isDec :: Char -> Bool
isDec c :: Char
c = Char
c Char -> Char -> Bool
forall a. Ord a => a -> a -> Bool
>= '0' Bool -> Bool -> Bool
&& Char
c Char -> Char -> Bool
forall a. Ord a => a -> a -> Bool
<= '9'

protectEsc :: (Char -> Bool) -> ShowS -> ShowS
protectEsc :: (Char -> Bool) -> ShowS -> ShowS
protectEsc p :: Char -> Bool
p f :: ShowS
f             = ShowS
f ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShowS
cont
                             where cont :: ShowS
cont s :: String
s@(c :: Char
c:_) | Char -> Bool
p Char
c = "\\&" String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
s
                                   cont s :: String
s             = String
s


asciiTab :: [String]
asciiTab :: [String]
asciiTab = -- Using an array drags in the array module.  listArray ('\NUL', ' ')
           ["NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL",
            "BS",  "HT",  "LF",  "VT",  "FF",  "CR",  "SO",  "SI",
            "DLE", "DC1", "DC2", "DC3", "DC4", "NAK", "SYN", "ETB",
            "CAN", "EM",  "SUB", "ESC", "FS",  "GS",  "RS",  "US",
            "SP"]

-- Code specific for Ints.

-- | Convert an 'Int' in the range @0@..@15@ to the corresponding single
-- digit 'Char'.  This function fails on other inputs, and generates
-- lower-case hexadecimal digits.
intToDigit :: Int -> Char
intToDigit :: Int -> Char
intToDigit (I# i :: Int#
i)
    | Int# -> Bool
isTrue# (Int#
i Int# -> Int# -> Int#
>=# 0#)  Bool -> Bool -> Bool
&& Int# -> Bool
isTrue# (Int#
i Int# -> Int# -> Int#
<=#  9#) = Int -> Char
unsafeChr (Char -> Int
ord '0' Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int# -> Int
I# Int#
i)
    | Int# -> Bool
isTrue# (Int#
i Int# -> Int# -> Int#
>=# 10#) Bool -> Bool -> Bool
&& Int# -> Bool
isTrue# (Int#
i Int# -> Int# -> Int#
<=# 15#) = Int -> Char
unsafeChr (Char -> Int
ord 'a' Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int# -> Int
I# Int#
i Int -> Int -> Int
forall a. Num a => a -> a -> a
- 10)
    | Bool
otherwise =  String -> Char
forall a. String -> a
errorWithoutStackTrace ("Char.intToDigit: not a digit " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Int -> String
forall a. Show a => a -> String
show (Int# -> Int
I# Int#
i))

showSignedInt :: Int -> Int -> ShowS
showSignedInt :: Int -> Int -> ShowS
showSignedInt (I# p :: Int#
p) (I# n :: Int#
n) r :: String
r
    | Int# -> Bool
isTrue# (Int#
n Int# -> Int# -> Int#
<# 0#) Bool -> Bool -> Bool
&& Int# -> Bool
isTrue# (Int#
p Int# -> Int# -> Int#
># 6#) = '(' Char -> ShowS
forall a. a -> [a] -> [a]
: Int# -> ShowS
itos Int#
n (')' Char -> ShowS
forall a. a -> [a] -> [a]
: String
r)
    | Bool
otherwise                              = Int# -> ShowS
itos Int#
n String
r

itos :: Int# -> String -> String
itos :: Int# -> ShowS
itos n# :: Int#
n# cs :: String
cs
    | Int# -> Bool
isTrue# (Int#
n# Int# -> Int# -> Int#
<# 0#) =
        let !(I# minInt# :: Int#
minInt#) = Int
minInt in
        if Int# -> Bool
isTrue# (Int#
n# Int# -> Int# -> Int#
==# Int#
minInt#)
                -- negateInt# minInt overflows, so we can't do that:
           then '-' Char -> ShowS
forall a. a -> [a] -> [a]
: (case Int#
n# Int# -> Int# -> (# Int#, Int# #)
`quotRemInt#` 10# of
                       (# q :: Int#
q, r :: Int#
r #) ->
                           Int# -> ShowS
itos' (Int# -> Int#
negateInt# Int#
q) (Int# -> ShowS
itos' (Int# -> Int#
negateInt# Int#
r) String
cs))
           else '-' Char -> ShowS
forall a. a -> [a] -> [a]
: Int# -> ShowS
itos' (Int# -> Int#
negateInt# Int#
n#) String
cs
    | Bool
otherwise = Int# -> ShowS
itos' Int#
n# String
cs
    where
    itos' :: Int# -> String -> String
    itos' :: Int# -> ShowS
itos' x# :: Int#
x# cs' :: String
cs'
        | Int# -> Bool
isTrue# (Int#
x# Int# -> Int# -> Int#
<# 10#) = Char# -> Char
C# (Int# -> Char#
chr# (Char# -> Int#
ord# '0'# Int# -> Int# -> Int#
+# Int#
x#)) Char -> ShowS
forall a. a -> [a] -> [a]
: String
cs'
        | Bool
otherwise = case Int#
x# Int# -> Int# -> (# Int#, Int# #)
`quotRemInt#` 10# of
                      (# q :: Int#
q, r :: Int#
r #) ->
                          case Int# -> Char#
chr# (Char# -> Int#
ord# '0'# Int# -> Int# -> Int#
+# Int#
r) of
                          c# :: Char#
c# ->
                              Int# -> ShowS
itos' Int#
q (Char# -> Char
C# Char#
c# Char -> ShowS
forall a. a -> [a] -> [a]
: String
cs')

--------------------------------------------------------------
-- The Integer instances for Show
--------------------------------------------------------------

-- | @since 2.01
instance Show Integer where
    showsPrec :: Int -> Integer -> ShowS
showsPrec p :: Int
p n :: Integer
n r :: String
r
        | Int
p Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> 6 Bool -> Bool -> Bool
&& Integer
n Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
< 0 = '(' Char -> ShowS
forall a. a -> [a] -> [a]
: Integer -> ShowS
integerToString Integer
n (')' Char -> ShowS
forall a. a -> [a] -> [a]
: String
r)
        -- Minor point: testing p first gives better code
        -- in the not-uncommon case where the p argument
        -- is a constant
        | Bool
otherwise = Integer -> ShowS
integerToString Integer
n String
r
    showList :: [Integer] -> ShowS
showList = (Integer -> ShowS) -> [Integer] -> ShowS
forall a. (a -> ShowS) -> [a] -> ShowS
showList__ (Int -> Integer -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec 0)

-- | @since 4.8.0.0
instance Show Natural where
#if defined(MIN_VERSION_integer_gmp)
    showsPrec :: Int -> Natural -> ShowS
showsPrec p :: Int
p (NatS# w# :: Word#
w#) = Int -> Word -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
p (Word# -> Word
W# Word#
w#)
#endif
    showsPrec p :: Int
p i :: Natural
i          = Int -> Integer -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
p (Natural -> Integer
naturalToInteger Natural
i)

-- Divide and conquer implementation of string conversion
integerToString :: Integer -> String -> String
integerToString :: Integer -> ShowS
integerToString n0 :: Integer
n0 cs0 :: String
cs0
    | Integer
n0 Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
< 0    = '-' Char -> ShowS
forall a. a -> [a] -> [a]
: Integer -> ShowS
integerToString' (- Integer
n0) String
cs0
    | Bool
otherwise = Integer -> ShowS
integerToString' Integer
n0 String
cs0
    where
    integerToString' :: Integer -> String -> String
    integerToString' :: Integer -> ShowS
integerToString' n :: Integer
n cs :: String
cs
        | Integer
n Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
< BASE  = jhead (fromInteger n) cs
        | Bool
otherwise = [Integer] -> ShowS
jprinth (Integer -> Integer -> [Integer]
jsplitf (BASE*BASE) n) cs

    -- Split n into digits in base p. We first split n into digits
    -- in base p*p and then split each of these digits into two.
    -- Note that the first 'digit' modulo p*p may have a leading zero
    -- in base p that we need to drop - this is what jsplith takes care of.
    -- jsplitb the handles the remaining digits.
    jsplitf :: Integer -> Integer -> [Integer]
    jsplitf :: Integer -> Integer -> [Integer]
jsplitf p :: Integer
p n :: Integer
n
        | Integer
p Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
> Integer
n     = [Integer
n]
        | Bool
otherwise = Integer -> [Integer] -> [Integer]
jsplith Integer
p (Integer -> Integer -> [Integer]
jsplitf (Integer
pInteger -> Integer -> Integer
forall a. Num a => a -> a -> a
*Integer
p) Integer
n)

    jsplith :: Integer -> [Integer] -> [Integer]
    jsplith :: Integer -> [Integer] -> [Integer]
jsplith p :: Integer
p (n :: Integer
n:ns :: [Integer]
ns) =
        case Integer
n Integer -> Integer -> (# Integer, Integer #)
`quotRemInteger` Integer
p of
        (# q :: Integer
q, r :: Integer
r #) ->
            if Integer
q Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
> 0 then Integer
q Integer -> [Integer] -> [Integer]
forall a. a -> [a] -> [a]
: Integer
r Integer -> [Integer] -> [Integer]
forall a. a -> [a] -> [a]
: Integer -> [Integer] -> [Integer]
jsplitb Integer
p [Integer]
ns
                     else     Integer
r Integer -> [Integer] -> [Integer]
forall a. a -> [a] -> [a]
: Integer -> [Integer] -> [Integer]
jsplitb Integer
p [Integer]
ns
    jsplith _ [] = String -> [Integer]
forall a. String -> a
errorWithoutStackTrace "jsplith: []"

    jsplitb :: Integer -> [Integer] -> [Integer]
    jsplitb :: Integer -> [Integer] -> [Integer]
jsplitb _ []     = []
    jsplitb p :: Integer
p (n :: Integer
n:ns :: [Integer]
ns) = case Integer
n Integer -> Integer -> (# Integer, Integer #)
`quotRemInteger` Integer
p of
                       (# q :: Integer
q, r :: Integer
r #) ->
                           Integer
q Integer -> [Integer] -> [Integer]
forall a. a -> [a] -> [a]
: Integer
r Integer -> [Integer] -> [Integer]
forall a. a -> [a] -> [a]
: Integer -> [Integer] -> [Integer]
jsplitb Integer
p [Integer]
ns

    -- Convert a number that has been split into digits in base BASE^2
    -- this includes a last splitting step and then conversion of digits
    -- that all fit into a machine word.
    jprinth :: [Integer] -> String -> String
    jprinth :: [Integer] -> ShowS
jprinth (n :: Integer
n:ns :: [Integer]
ns) cs :: String
cs =
        case Integer
n Integer -> Integer -> (# Integer, Integer #)
`quotRemInteger` BASE of
        (# q' :: Integer
q', r' :: Integer
r' #) ->
            let q :: Int
q = Integer -> Int
forall a. Num a => Integer -> a
fromInteger Integer
q'
                r :: Int
r = Integer -> Int
forall a. Num a => Integer -> a
fromInteger Integer
r'
            in if Int
q Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> 0 then Int -> ShowS
jhead Int
q ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ Int -> ShowS
jblock Int
r ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ [Integer] -> ShowS
jprintb [Integer]
ns String
cs
                        else Int -> ShowS
jhead Int
r ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ [Integer] -> ShowS
jprintb [Integer]
ns String
cs
    jprinth [] _ = ShowS
forall a. String -> a
errorWithoutStackTrace "jprinth []"

    jprintb :: [Integer] -> String -> String
    jprintb :: [Integer] -> ShowS
jprintb []     cs :: String
cs = String
cs
    jprintb (n :: Integer
n:ns :: [Integer]
ns) cs :: String
cs = case Integer
n Integer -> Integer -> (# Integer, Integer #)
`quotRemInteger` BASE of
                        (# q' :: Integer
q', r' :: Integer
r' #) ->
                            let q :: Int
q = Integer -> Int
forall a. Num a => Integer -> a
fromInteger Integer
q'
                                r :: Int
r = Integer -> Int
forall a. Num a => Integer -> a
fromInteger Integer
r'
                            in Int -> ShowS
jblock Int
q ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ Int -> ShowS
jblock Int
r ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ [Integer] -> ShowS
jprintb [Integer]
ns String
cs

    -- Convert an integer that fits into a machine word. Again, we have two
    -- functions, one that drops leading zeros (jhead) and one that doesn't
    -- (jblock)
    jhead :: Int -> String -> String
    jhead :: Int -> ShowS
jhead n :: Int
n cs :: String
cs
        | Int
n Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< 10    = case Int -> Char
unsafeChr (Char -> Int
ord '0' Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
n) of
            c :: Char
c@(C# _) -> Char
c Char -> ShowS
forall a. a -> [a] -> [a]
: String
cs
        | Bool
otherwise = case Int -> Char
unsafeChr (Char -> Int
ord '0' Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
r) of
            c :: Char
c@(C# _) -> Int -> ShowS
jhead Int
q (Char
c Char -> ShowS
forall a. a -> [a] -> [a]
: String
cs)
        where
        (q :: Int
q, r :: Int
r) = Int
n Int -> Int -> (Int, Int)
`quotRemInt` 10

    jblock :: Int -> ShowS
jblock = Int -> Int -> ShowS
jblock' {- ' -} DIGITS

    jblock' :: Int -> Int -> String -> String
    jblock' :: Int -> Int -> ShowS
jblock' d :: Int
d n :: Int
n cs :: String
cs
        | Int
d Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== 1    = case Int -> Char
unsafeChr (Char -> Int
ord '0' Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
n) of
             c :: Char
c@(C# _) -> Char
c Char -> ShowS
forall a. a -> [a] -> [a]
: String
cs
        | Bool
otherwise = case Int -> Char
unsafeChr (Char -> Int
ord '0' Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
r) of
             c :: Char
c@(C# _) -> Int -> Int -> ShowS
jblock' (Int
d Int -> Int -> Int
forall a. Num a => a -> a -> a
- 1) Int
q (Char
c Char -> ShowS
forall a. a -> [a] -> [a]
: String
cs)
        where
        (q :: Int
q, r :: Int
r) = Int
n Int -> Int -> (Int, Int)
`quotRemInt` 10

instance Show KindRep where
  showsPrec :: Int -> KindRep -> ShowS
showsPrec d :: Int
d (KindRepVar v :: Int
v) = Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> 10) (ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$
    String -> ShowS
showString "KindRepVar " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Int -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec 11 Int
v
  showsPrec d :: Int
d (KindRepTyConApp p :: TyCon
p q :: [KindRep]
q) = Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> 10) (ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$
    String -> ShowS
showString "KindRepTyConApp "
      ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> TyCon -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec 11 TyCon
p
      ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString " "
      ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> [KindRep] -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec 11 [KindRep]
q
  showsPrec d :: Int
d (KindRepApp p :: KindRep
p q :: KindRep
q) = Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> 10) (ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$
    String -> ShowS
showString "KindRepApp "
      ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> KindRep -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec 11 KindRep
p
      ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString " "
      ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> KindRep -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec 11 KindRep
q
  showsPrec d :: Int
d (KindRepFun p :: KindRep
p q :: KindRep
q) = Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> 10) (ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$
    String -> ShowS
showString "KindRepFun "
      ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> KindRep -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec 11 KindRep
p
      ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString " "
      ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> KindRep -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec 11 KindRep
q
  showsPrec d :: Int
d (KindRepTYPE rep :: RuntimeRep
rep) = Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> 10) (ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$
    String -> ShowS
showString "KindRepTYPE " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> RuntimeRep -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec 11 RuntimeRep
rep
  showsPrec d :: Int
d (KindRepTypeLitS p :: TypeLitSort
p q :: Addr#
q) = Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> 10) (ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$
    String -> ShowS
showString "KindRepTypeLitS "
      ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> TypeLitSort -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec 11 TypeLitSort
p
      ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString " "
      ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> String -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec 11 (Addr# -> String
unpackCString# Addr#
q)
  showsPrec d :: Int
d (KindRepTypeLitD p :: TypeLitSort
p q :: String
q) = Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> 10) (ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$
    String -> ShowS
showString "KindRepTypeLitD "
      ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> TypeLitSort -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec 11 TypeLitSort
p
      ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString " "
      ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> String -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec 11 String
q

-- | @since 4.11.0.0
deriving instance Show RuntimeRep

-- | @since 4.11.0.0
deriving instance Show VecCount

-- | @since 4.11.0.0
deriving instance Show VecElem

-- | @since 4.11.0.0
deriving instance Show TypeLitSort