{-# 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
#endif
module GHC.Show
(
Show(..), ShowS,
shows, showChar, showString, showMultiLineString,
showParen, showList__, showCommaSpace, showSpace,
showLitChar, showLitString, protectEsc,
intToDigit, showSignedInt,
appPrec, appPrec1,
asciiTab,
)
where
import GHC.Base
import GHC.List ((!!), foldr1, break)
import GHC.Num
import GHC.Stack.Types
type ShowS = String -> String
class Show a where
{-# MINIMAL showsPrec | show #-}
showsPrec :: Int
-> a
-> ShowS
show :: a -> String
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
appPrec :: Int
appPrec = Int# -> Int
I# 10#
appPrec1 :: Int
appPrec1 = Int# -> Int
I# 11#
deriving instance Show ()
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
deriving instance Show Bool
deriving instance Show Ordering
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 '"'
instance Show Int where
showsPrec :: Int -> Int -> ShowS
showsPrec = Int -> Int -> ShowS
showSignedInt
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)
deriving instance Show a => Show (Maybe a)
deriving instance Show a => Show (NonEmpty a)
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
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
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
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
deriving instance Show SrcLoc
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
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
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
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
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
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
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
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
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
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
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
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
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
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 ')'
shows :: (Show a) => a -> ShowS
shows :: a -> ShowS
shows = Int -> a -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec 0
showChar :: Char -> ShowS
showChar :: Char -> ShowS
showChar = (:)
showString :: String -> ShowS
showString :: String -> ShowS
showString = String -> ShowS
forall a. [a] -> [a] -> [a]
(++)
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 = \ xs :: String
xs -> ' ' Char -> ShowS
forall a. a -> [a] -> [a]
: String
xs
showCommaSpace :: ShowS
showCommaSpace :: ShowS
showCommaSpace = String -> ShowS
showString ", "
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
showLitString :: String -> ShowS
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)
showMultiLineString :: String -> [String]
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 =
["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"]
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#)
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')
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)
| 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)
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)
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
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
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
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
deriving instance Show RuntimeRep
deriving instance Show VecCount
deriving instance Show VecElem
deriving instance Show TypeLitSort