{-# 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.Internal.Show
-- Copyright   :  (c) The University of Glasgow, 1992-2002
-- License     :  see libraries/base/LICENSE
--
-- Maintainer  :  ghc-devs@haskell.org
-- Stability   :  internal
-- Portability :  non-portable (GHC Extensions)
--
-- The 'Show' class, and related operations.
--
-----------------------------------------------------------------------------

module GHC.Internal.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.Internal.Base
import GHC.Internal.List ((!!), foldr1, break)
import GHC.Internal.Num
import GHC.Internal.Stack.Types
import GHC.Tuple (Solo (..))


-- | 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
    --   @('GHC.Internal.Text.Read.readsPrec' d ('showsPrec' d x \"\"))@.
    --
    -- That is, 'GHC.Internal.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 Int
_ a
x String
s = a -> String
forall a. Show a => a -> String
show a
x String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
s
    show a
x          = a -> ShowS
forall a. Show a => a -> ShowS
shows a
x String
""
    showList [a]
ls   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__ :: forall a. (a -> ShowS) -> [a] -> ShowS
showList__ a -> ShowS
_     []     String
s = String
"[]" String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
s
showList__ a -> ShowS
showx (a
x:[a]
xs) String
s = Char
'[' Char -> ShowS
forall a. a -> [a] -> [a]
: a -> ShowS
showx a
x ([a] -> String
showl [a]
xs)
  where
    showl :: [a] -> String
showl []     = Char
']' Char -> ShowS
forall a. a -> [a] -> [a]
: String
s
    showl (a
y:[a]
ys) = Char
',' 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# Int#
10#        -- Precedence of application:
                        --   one more than the maximum operator precedence of 9
appPrec1 :: Int
appPrec1 = Int# -> Int
I# Int#
11#       -- appPrec + 1

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

-- | @since base-4.8.0.0
deriving instance Show Void

-- | @since base-2.01
deriving instance Show ()

-- | @since base-4.15
deriving instance Show a => Show (Solo a)

-- | @since base-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 Int
_         = [a] -> ShowS
forall a. Show a => [a] -> ShowS
showList

-- | @since base-2.01
deriving instance Show Bool

-- | @since base-2.01
deriving instance Show Ordering

-- | @since base-2.01
instance  Show Char  where
    showsPrec :: Int -> Char -> ShowS
showsPrec Int
_ Char
'\'' = String -> ShowS
showString String
"'\\''"
    showsPrec Int
_ Char
c    = Char -> ShowS
showChar Char
'\'' 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 Char
'\''

    showList :: String -> ShowS
showList String
cs = Char -> ShowS
showChar Char
'"' 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 Char
'"'

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

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

showWord :: Word# -> ShowS
showWord :: Word# -> ShowS
showWord Word#
w# String
cs
 | Int# -> Bool
isTrue# (Word#
w# Word# -> Word# -> Int#
`ltWord#` Word#
10##) = Char# -> Char
C# (Int# -> Char#
chr# (Char# -> Int#
ord# Char#
'0'# Int# -> Int# -> Int#
+# Word# -> Int#
word2Int# Word#
w#)) Char -> ShowS
forall a. a -> [a] -> [a]
: String
cs
 | Bool
otherwise =
    let
      !(# Word#
q, Word#
r #) = Word# -> Word# -> (# Word#, Word# #)
quotRemWord# Word#
w# Word#
10##
      !c# :: Char#
c#         = Int# -> Char#
chr# (Char# -> Int#
ord# Char#
'0'# Int# -> Int# -> Int#
+# Word# -> Int#
word2Int# Word#
r)
    in Word# -> ShowS
showWord Word#
q (Char# -> Char
C# Char#
c# Char -> ShowS
forall a. a -> [a] -> [a]
: String
cs)

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

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

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

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

-- | @since base-4.9.0.0
instance Show Module where
  showsPrec :: Int -> Module -> ShowS
showsPrec Int
_ (Module TrName
p 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
':' 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 base-4.9.0.0
instance Show CallStack where
  showsPrec :: Int -> CallStack -> ShowS
showsPrec Int
_ = [(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 base-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 base-2.01
instance  (Show a, Show b) => Show (a,b)  where
  showsPrec :: Int -> (a, b) -> ShowS
showsPrec Int
_ (a
a,b
b) 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 base-2.01
instance (Show a, Show b, Show c) => Show (a, b, c) where
  showsPrec :: Int -> (a, b, c) -> ShowS
showsPrec Int
_ (a
a,b
b,c
c) 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 base-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 Int
_ (a
a,b
b,c
c,d
d) 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 base-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 Int
_ (a
a,b
b,c
c,d
d,e
e) 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 base-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 Int
_ (a
a,b
b,c
c,d
d,e
e,f
f) 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 base-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 Int
_ (a
a,b
b,c
c,d
d,e
e,f
f,g
g) 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 base-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 Int
_ (a
a,b
b,c
c,d
d,e
e,f
f,g
g,h
h) 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 base-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 Int
_ (a
a,b
b,c
c,d
d,e
e,f
f,g
g,h
h,i
i) 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 base-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 Int
_ (a
a,b
b,c
c,d
d,e
e,f
f,g
g,h
h,i
i,j
j) 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 base-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 Int
_ (a
a,b
b,c
c,d
d,e
e,f
f,g
g,h
h,i
i,j
j,k
k) 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 base-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 Int
_ (a
a,b
b,c
c,d
d,e
e,f
f,g
g,h
h,i
i,j
j,k
k,l
l) 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 base-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 Int
_ (a
a,b
b,c
c,d
d,e
e,f
f,g
g,h
h,i
i,j
j,k
k,l
l,m
m) 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 base-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 Int
_ (a
a,b
b,c
c,d
d,e
e,f
f,g
g,h
h,i
i,j
j,k
k,l
l,m
m,n
n) 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 base-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 Int
_ (a
a,b
b,c
c,d
d,e
e,f
f,g
g,h
h,i
i,j
j,k
k,l
l,m
m,n
n,o
o) 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 [ShowS]
ss = Char -> ShowS
showChar Char
'('
              ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ShowS -> ShowS -> ShowS) -> [ShowS] -> ShowS
forall a. HasCallStack => (a -> a -> a) -> [a] -> a
foldr1 (\ShowS
s ShowS
r -> ShowS
s ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> ShowS
showChar Char
',' 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 Char
')'

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

-- | equivalent to 'showsPrec' with a precedence of 0.
shows           :: (Show a) => a -> ShowS
shows :: forall a. Show a => a -> ShowS
shows           =  Int -> a -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
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 Bool
b ShowS
p   =  if Bool
b then Char -> ShowS
showChar Char
'(' 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 Char
')' else ShowS
p

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

showCommaSpace :: ShowS
showCommaSpace :: ShowS
showCommaSpace = String -> ShowS
showString String
", "
-- 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 Char
c String
s | Char
c Char -> Char -> Bool
forall a. Ord a => a -> a -> Bool
> Char
'\DEL' =  Char -> ShowS
showChar Char
'\\' ((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 Char
'\DEL'         String
s =  String -> ShowS
showString String
"\\DEL" String
s
showLitChar Char
'\\'           String
s =  String -> ShowS
showString String
"\\\\" String
s
showLitChar Char
c String
s | Char
c Char -> Char -> Bool
forall a. Ord a => a -> a -> Bool
>= Char
' '   =  Char -> ShowS
showChar Char
c String
s
showLitChar Char
'\a'           String
s =  String -> ShowS
showString String
"\\a" String
s
showLitChar Char
'\b'           String
s =  String -> ShowS
showString String
"\\b" String
s
showLitChar Char
'\f'           String
s =  String -> ShowS
showString String
"\\f" String
s
showLitChar Char
'\n'           String
s =  String -> ShowS
showString String
"\\n" String
s
showLitChar Char
'\r'           String
s =  String -> ShowS
showString String
"\\r" String
s
showLitChar Char
'\t'           String
s =  String -> ShowS
showString String
"\\t" String
s
showLitChar Char
'\v'           String
s =  String -> ShowS
showString String
"\\v" String
s
showLitChar Char
'\SO'          String
s =  (Char -> Bool) -> ShowS -> ShowS
protectEsc (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
'H') (String -> ShowS
showString String
"\\SO") String
s
showLitChar Char
c              String
s =  String -> ShowS
showString (Char
'\\' Char -> ShowS
forall a. a -> [a] -> [a]
: [String]
asciiTab[String] -> Int -> String
forall a. HasCallStack => [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 []         String
s = String
s
showLitString (Char
'"' : String
cs) String
s = String -> ShowS
showString String
"\\\"" (String -> ShowS
showLitString String
cs String
s)
showLitString (Char
c   : String
cs) 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 String
str
  = Char -> String -> [String]
go Char
'\"' String
str
  where
    go :: Char -> String -> [String]
go Char
ch 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
== Char
'\n') String
s of
                (String
l, Char
_:s' :: String
s'@(Char
_:String
_)) -> (Char
ch Char -> ShowS
forall a. a -> [a] -> [a]
: String -> ShowS
showLitString String
l String
"\\n\\") String -> [String] -> [String]
forall a. a -> [a] -> [a]
: Char -> String -> [String]
go Char
'\\' String
s'
                (String
l, String
"\n")       -> [Char
ch Char -> ShowS
forall a. a -> [a] -> [a]
: String -> ShowS
showLitString String
l String
"\\n\""]
                (String
l, String
_)          -> [Char
ch Char -> ShowS
forall a. a -> [a] -> [a]
: String -> ShowS
showLitString String
l String
"\""]

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

protectEsc :: (Char -> Bool) -> ShowS -> ShowS
protectEsc :: (Char -> Bool) -> ShowS -> ShowS
protectEsc Char -> Bool
p 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@(Char
c:String
_) | Char -> Bool
p Char
c = String
"\\&" String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
s
                                   cont String
s             = String
s


asciiTab :: [String]
asciiTab :: [String]
asciiTab = -- Using an array drags in the array module.  listArray ('\NUL', ' ')
           [String
"NUL", String
"SOH", String
"STX", String
"ETX", String
"EOT", String
"ENQ", String
"ACK", String
"BEL",
            String
"BS",  String
"HT",  String
"LF",  String
"VT",  String
"FF",  String
"CR",  String
"SO",  String
"SI",
            String
"DLE", String
"DC1", String
"DC2", String
"DC3", String
"DC4", String
"NAK", String
"SYN", String
"ETB",
            String
"CAN", String
"EM",  String
"SUB", String
"ESC", String
"FS",  String
"GS",  String
"RS",  String
"US",
            String
"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# Int#
i)
    | Int# -> Bool
isTrue# (Int#
i Int# -> Int# -> Int#
>=# Int#
0#)  Bool -> Bool -> Bool
&& Int# -> Bool
isTrue# (Int#
i Int# -> Int# -> Int#
<=#  Int#
9#) = Int -> Char
unsafeChr (Char -> Int
ord Char
'0' Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int# -> Int
I# Int#
i)
    | Int# -> Bool
isTrue# (Int#
i Int# -> Int# -> Int#
>=# Int#
10#) Bool -> Bool -> Bool
&& Int# -> Bool
isTrue# (Int#
i Int# -> Int# -> Int#
<=# Int#
15#) = Int -> Char
unsafeChr (Char -> Int
ord Char
'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
- Int
10)
    | Bool
otherwise =  String -> Char
forall a. String -> a
errorWithoutStackTrace (String
"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# Int#
p) (I# Int#
n) String
r
    | Int# -> Bool
isTrue# (Int#
n Int# -> Int# -> Int#
<# Int#
0#) Bool -> Bool -> Bool
&& Int# -> Bool
isTrue# (Int#
p Int# -> Int# -> Int#
># Int#
6#) = Char
'(' Char -> ShowS
forall a. a -> [a] -> [a]
: Int# -> ShowS
itos Int#
n (Char
')' 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 Int#
n# String
cs
    | Int# -> Bool
isTrue# (Int#
n# Int# -> Int# -> Int#
<# Int#
0#) =
        let !(I# 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
'-' Char -> ShowS
forall a. a -> [a] -> [a]
: (case Int#
n# Int# -> Int# -> (# Int#, Int# #)
`quotRemInt#` Int#
10# of
                       (# Int#
q, Int#
r #) ->
                           Int# -> ShowS
itos' (Int# -> Int#
negateInt# Int#
q) (Int# -> ShowS
itos' (Int# -> Int#
negateInt# Int#
r) String
cs))
           else Char
'-' 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' Int#
x# String
cs'
        | Int# -> Bool
isTrue# (Int#
x# Int# -> Int# -> Int#
<# Int#
10#) = Char# -> Char
C# (Int# -> Char#
chr# (Char# -> Int#
ord# Char#
'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#` Int#
10# of
                      (# Int#
q, Int#
r #) ->
                          case Int# -> Char#
chr# (Char# -> Int#
ord# Char#
'0'# Int# -> Int# -> Int#
+# Int#
r) of
                          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 base-2.01
instance Show Integer where
    showsPrec :: Int -> Integer -> ShowS
showsPrec Int
p (IS Int#
i) String
r = Int -> Int -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
p (Int# -> Int
I# Int#
i) String
r
    showsPrec Int
p Integer
n String
r
        | Int
p Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
6 Bool -> Bool -> Bool
&& Integer
n Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
< Integer
0 = Char
'(' Char -> ShowS
forall a. a -> [a] -> [a]
: Integer -> ShowS
integerToString Integer
n (Char
')' 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 Int
0)

-- | @since base-4.8.0.0
instance Show Natural where
    showsPrec :: Int -> Natural -> ShowS
showsPrec Int
p (NS Word#
w) = Int -> Word -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
p (Word# -> Word
W# Word#
w)
    showsPrec Int
p Natural
n      = Int -> Integer -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
p (Natural -> Integer
integerFromNatural Natural
n)

-- Divide and conquer implementation of string conversion
integerToString :: Integer -> String -> String
integerToString :: Integer -> ShowS
integerToString Integer
n0 String
cs0
    | Integer
n0 Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
< Integer
0    = Char
'-' 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' Integer
n 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 Integer
p 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 Integer
p (Integer
n:[Integer]
ns) =
        case Integer
n Integer -> Integer -> (# Integer, Integer #)
`integerQuotRem#` Integer
p of
        (# Integer
q, Integer
r #) ->
            if Integer
q Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
> Integer
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 Integer
_ [] = String -> [Integer]
forall a. String -> a
errorWithoutStackTrace String
"jsplith: []"

    jsplitb :: Integer -> [Integer] -> [Integer]
    jsplitb :: Integer -> [Integer] -> [Integer]
jsplitb Integer
_ []     = []
    jsplitb Integer
p (Integer
n:[Integer]
ns) = case Integer
n Integer -> Integer -> (# Integer, Integer #)
`integerQuotRem#` Integer
p of
                       (# Integer
q, 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 (Integer
n:[Integer]
ns) String
cs =
        case Integer
n Integer -> Integer -> (# Integer, Integer #)
`integerQuotRem#` BASE of
        (# Integer
q', 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
> Int
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 [] String
_ = ShowS
forall a. String -> a
errorWithoutStackTrace String
"jprinth []"

    jprintb :: [Integer] -> String -> String
    jprintb :: [Integer] -> ShowS
jprintb []     String
cs = String
cs
    jprintb (Integer
n:[Integer]
ns) String
cs = case Integer
n Integer -> Integer -> (# Integer, Integer #)
`integerQuotRem#` BASE of
                        (# Integer
q', 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 Int
n String
cs
        | Int
n Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< Int
10    = case Int -> Char
unsafeChr (Char -> Int
ord Char
'0' Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
n) of
            c :: Char
c@(C# Char#
_) -> Char
c Char -> ShowS
forall a. a -> [a] -> [a]
: String
cs
        | Bool
otherwise = case Int -> Char
unsafeChr (Char -> Int
ord Char
'0' Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
r) of
            c :: Char
c@(C# Char#
_) -> Int -> ShowS
jhead Int
q (Char
c Char -> ShowS
forall a. a -> [a] -> [a]
: String
cs)
        where
        (Int
q, Int
r) = Int
n Int -> Int -> (Int, Int)
`quotRemInt` Int
10

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

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

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

-- | @since base-4.15.0.0
deriving instance Show Levity

-- | @since base-4.11.0.0
deriving instance Show RuntimeRep

-- | @since base-4.11.0.0
deriving instance Show VecCount

-- | @since base-4.11.0.0
deriving instance Show VecElem

-- | @since base-4.11.0.0
deriving instance Show TypeLitSort