{-# 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
import GHC.Tuple (Solo (..))
type ShowS = String -> String
class Show a where
{-# MINIMAL showsPrec | show #-}
showsPrec :: Int
-> a
-> ShowS
show :: a -> String
showList :: [a] -> ShowS
showsPrec Int
_ a
x String
s = forall a. Show a => a -> String
show a
x forall a. [a] -> [a] -> [a]
++ String
s
show a
x = forall a. Show a => a -> ShowS
shows a
x String
""
showList [a]
ls String
s = forall a. (a -> ShowS) -> [a] -> ShowS
showList__ 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
"[]" forall a. [a] -> [a] -> [a]
++ String
s
showList__ a -> ShowS
showx (a
x:[a]
xs) String
s = Char
'[' forall a. a -> [a] -> [a]
: a -> ShowS
showx a
x ([a] -> String
showl [a]
xs)
where
showl :: [a] -> String
showl [] = Char
']' forall a. a -> [a] -> [a]
: String
s
showl (a
y:[a]
ys) = Char
',' forall a. a -> [a] -> [a]
: a -> ShowS
showx a
y ([a] -> String
showl [a]
ys)
appPrec, appPrec1 :: Int
appPrec :: Int
appPrec = Int# -> Int
I# Int#
10#
appPrec1 :: Int
appPrec1 = Int# -> Int
I# Int#
11#
deriving instance Show ()
deriving instance Show a => Show (Solo a)
instance Show a => Show [a] where
{-# SPECIALISE instance Show [String] #-}
{-# SPECIALISE instance Show [Char] #-}
{-# SPECIALISE instance Show [Int] #-}
showsPrec :: Int -> [a] -> ShowS
showsPrec Int
_ = forall a. Show a => [a] -> ShowS
showList
deriving instance Show Bool
deriving instance Show Ordering
instance Show Char where
showsPrec :: Int -> Char -> ShowS
showsPrec Int
_ Char
'\'' = String -> ShowS
showString String
"'\\''"
showsPrec Int
_ Char
c = Char -> ShowS
showChar Char
'\'' forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> ShowS
showLitChar Char
c forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> ShowS
showChar Char
'\''
showList :: String -> ShowS
showList String
cs = Char -> ShowS
showChar Char
'"' forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showLitString String
cs forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> ShowS
showChar Char
'"'
instance Show Int where
showsPrec :: Int -> Int -> ShowS
showsPrec = Int -> Int -> ShowS
showSignedInt
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#)) forall a. a -> [a] -> [a]
: String
cs
| Bool
otherwise = case Int# -> Char#
chr# (Char# -> Int#
ord# Char#
'0'# Int# -> Int# -> Int#
+# Word# -> Int#
word2Int# (Word#
w# Word# -> Word# -> Word#
`remWord#` Word#
10##)) of
Char#
c# ->
Word# -> ShowS
showWord (Word#
w# Word# -> Word# -> Word#
`quotWord#` Word#
10##) (Char# -> Char
C# Char#
c# 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 Int
p (TyCon Word#
_ Word#
_ Module
_ TrName
tc_name Int#
_ KindRep
_) = forall a. Show a => Int -> a -> ShowS
showsPrec Int
p TrName
tc_name
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
instance Show Module where
showsPrec :: Int -> Module -> ShowS
showsPrec Int
_ (Module TrName
p TrName
m) = forall a. Show a => a -> ShowS
shows TrName
p forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char
':' forall a. a -> [a] -> [a]
:) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Show a => a -> ShowS
shows TrName
m
instance Show CallStack where
showsPrec :: Int -> CallStack -> ShowS
showsPrec Int
_ = forall a. Show a => a -> ShowS
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 Int
_ (a
a,b
b) String
s = [ShowS] -> ShowS
show_tuple [forall a. Show a => a -> ShowS
shows a
a, 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 Int
_ (a
a,b
b,c
c) String
s = [ShowS] -> ShowS
show_tuple [forall a. Show a => a -> ShowS
shows a
a, forall a. Show a => a -> ShowS
shows b
b, 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 Int
_ (a
a,b
b,c
c,d
d) String
s = [ShowS] -> ShowS
show_tuple [forall a. Show a => a -> ShowS
shows a
a, forall a. Show a => a -> ShowS
shows b
b, forall a. Show a => a -> ShowS
shows c
c, 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 Int
_ (a
a,b
b,c
c,d
d,e
e) String
s = [ShowS] -> ShowS
show_tuple [forall a. Show a => a -> ShowS
shows a
a, forall a. Show a => a -> ShowS
shows b
b, forall a. Show a => a -> ShowS
shows c
c, forall a. Show a => a -> ShowS
shows d
d, 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 Int
_ (a
a,b
b,c
c,d
d,e
e,f
f) String
s = [ShowS] -> ShowS
show_tuple [forall a. Show a => a -> ShowS
shows a
a, forall a. Show a => a -> ShowS
shows b
b, forall a. Show a => a -> ShowS
shows c
c, forall a. Show a => a -> ShowS
shows d
d, forall a. Show a => a -> ShowS
shows e
e, 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 Int
_ (a
a,b
b,c
c,d
d,e
e,f
f,g
g) String
s
= [ShowS] -> ShowS
show_tuple [forall a. Show a => a -> ShowS
shows a
a, forall a. Show a => a -> ShowS
shows b
b, forall a. Show a => a -> ShowS
shows c
c, forall a. Show a => a -> ShowS
shows d
d, forall a. Show a => a -> ShowS
shows e
e, forall a. Show a => a -> ShowS
shows f
f, 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 Int
_ (a
a,b
b,c
c,d
d,e
e,f
f,g
g,h
h) String
s
= [ShowS] -> ShowS
show_tuple [forall a. Show a => a -> ShowS
shows a
a, forall a. Show a => a -> ShowS
shows b
b, forall a. Show a => a -> ShowS
shows c
c, forall a. Show a => a -> ShowS
shows d
d, forall a. Show a => a -> ShowS
shows e
e, forall a. Show a => a -> ShowS
shows f
f, forall a. Show a => a -> ShowS
shows g
g, 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 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 [forall a. Show a => a -> ShowS
shows a
a, forall a. Show a => a -> ShowS
shows b
b, forall a. Show a => a -> ShowS
shows c
c, forall a. Show a => a -> ShowS
shows d
d, forall a. Show a => a -> ShowS
shows e
e, forall a. Show a => a -> ShowS
shows f
f, forall a. Show a => a -> ShowS
shows g
g, forall a. Show a => a -> ShowS
shows h
h,
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 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 [forall a. Show a => a -> ShowS
shows a
a, forall a. Show a => a -> ShowS
shows b
b, forall a. Show a => a -> ShowS
shows c
c, forall a. Show a => a -> ShowS
shows d
d, forall a. Show a => a -> ShowS
shows e
e, forall a. Show a => a -> ShowS
shows f
f, forall a. Show a => a -> ShowS
shows g
g, forall a. Show a => a -> ShowS
shows h
h,
forall a. Show a => a -> ShowS
shows i
i, 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 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 [forall a. Show a => a -> ShowS
shows a
a, forall a. Show a => a -> ShowS
shows b
b, forall a. Show a => a -> ShowS
shows c
c, forall a. Show a => a -> ShowS
shows d
d, forall a. Show a => a -> ShowS
shows e
e, forall a. Show a => a -> ShowS
shows f
f, forall a. Show a => a -> ShowS
shows g
g, forall a. Show a => a -> ShowS
shows h
h,
forall a. Show a => a -> ShowS
shows i
i, forall a. Show a => a -> ShowS
shows j
j, 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 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 [forall a. Show a => a -> ShowS
shows a
a, forall a. Show a => a -> ShowS
shows b
b, forall a. Show a => a -> ShowS
shows c
c, forall a. Show a => a -> ShowS
shows d
d, forall a. Show a => a -> ShowS
shows e
e, forall a. Show a => a -> ShowS
shows f
f, forall a. Show a => a -> ShowS
shows g
g, forall a. Show a => a -> ShowS
shows h
h,
forall a. Show a => a -> ShowS
shows i
i, forall a. Show a => a -> ShowS
shows j
j, forall a. Show a => a -> ShowS
shows k
k, 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 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 [forall a. Show a => a -> ShowS
shows a
a, forall a. Show a => a -> ShowS
shows b
b, forall a. Show a => a -> ShowS
shows c
c, forall a. Show a => a -> ShowS
shows d
d, forall a. Show a => a -> ShowS
shows e
e, forall a. Show a => a -> ShowS
shows f
f, forall a. Show a => a -> ShowS
shows g
g, forall a. Show a => a -> ShowS
shows h
h,
forall a. Show a => a -> ShowS
shows i
i, forall a. Show a => a -> ShowS
shows j
j, forall a. Show a => a -> ShowS
shows k
k, forall a. Show a => a -> ShowS
shows l
l, 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 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 [forall a. Show a => a -> ShowS
shows a
a, forall a. Show a => a -> ShowS
shows b
b, forall a. Show a => a -> ShowS
shows c
c, forall a. Show a => a -> ShowS
shows d
d, forall a. Show a => a -> ShowS
shows e
e, forall a. Show a => a -> ShowS
shows f
f, forall a. Show a => a -> ShowS
shows g
g, forall a. Show a => a -> ShowS
shows h
h,
forall a. Show a => a -> ShowS
shows i
i, forall a. Show a => a -> ShowS
shows j
j, forall a. Show a => a -> ShowS
shows k
k, forall a. Show a => a -> ShowS
shows l
l, forall a. Show a => a -> ShowS
shows m
m, 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 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 [forall a. Show a => a -> ShowS
shows a
a, forall a. Show a => a -> ShowS
shows b
b, forall a. Show a => a -> ShowS
shows c
c, forall a. Show a => a -> ShowS
shows d
d, forall a. Show a => a -> ShowS
shows e
e, forall a. Show a => a -> ShowS
shows f
f, forall a. Show a => a -> ShowS
shows g
g, forall a. Show a => a -> ShowS
shows h
h,
forall a. Show a => a -> ShowS
shows i
i, forall a. Show a => a -> ShowS
shows j
j, forall a. Show a => a -> ShowS
shows k
k, forall a. Show a => a -> ShowS
shows l
l, forall a. Show a => a -> ShowS
shows m
m, forall a. Show a => a -> ShowS
shows n
n, 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
'('
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. (a -> a -> a) -> [a] -> a
foldr1 (\ShowS
s ShowS
r -> ShowS
s forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> ShowS
showChar Char
',' forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShowS
r) [ShowS]
ss
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> ShowS
showChar Char
')'
shows :: (Show a) => a -> ShowS
shows :: forall a. Show a => a -> ShowS
shows = forall a. Show a => Int -> a -> ShowS
showsPrec Int
0
showChar :: Char -> ShowS
showChar :: Char -> ShowS
showChar = (:)
showString :: String -> ShowS
showString :: String -> ShowS
showString = forall a. [a] -> [a] -> [a]
(++)
showParen :: Bool -> ShowS -> ShowS
showParen :: Bool -> ShowS -> ShowS
showParen Bool
b ShowS
p = if Bool
b then Char -> ShowS
showChar Char
'(' forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShowS
p forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> ShowS
showChar Char
')' else ShowS
p
showSpace :: ShowS
showSpace :: ShowS
showSpace = \ String
xs -> Char
' ' forall a. a -> [a] -> [a]
: String
xs
showCommaSpace :: ShowS
showCommaSpace :: ShowS
showCommaSpace = String -> ShowS
showString String
", "
showLitChar :: Char -> ShowS
showLitChar :: Char -> ShowS
showLitChar Char
c String
s | Char
c forall a. Ord a => a -> a -> Bool
> Char
'\DEL' = Char -> ShowS
showChar Char
'\\' ((Char -> Bool) -> ShowS -> ShowS
protectEsc Char -> Bool
isDec (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 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 (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
'\\' forall a. a -> [a] -> [a]
: [String]
asciiTabforall a. [a] -> Int -> a
!!Char -> Int
ord Char
c) String
s
showLitString :: String -> ShowS
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)
showMultiLineString :: String -> [String]
showMultiLineString :: String -> [String]
showMultiLineString String
str
= Char -> String -> [String]
go Char
'\"' String
str
where
go :: Char -> String -> [String]
go Char
ch String
s = case forall a. (a -> Bool) -> [a] -> ([a], [a])
break (forall a. Eq a => a -> a -> Bool
== Char
'\n') String
s of
(String
l, Char
_:s' :: String
s'@(Char
_:String
_)) -> (Char
ch forall a. a -> [a] -> [a]
: String -> ShowS
showLitString String
l String
"\\n\\") forall a. a -> [a] -> [a]
: Char -> String -> [String]
go Char
'\\' String
s'
(String
l, String
"\n") -> [Char
ch forall a. a -> [a] -> [a]
: String -> ShowS
showLitString String
l String
"\\n\""]
(String
l, String
_) -> [Char
ch forall a. a -> [a] -> [a]
: String -> ShowS
showLitString String
l String
"\""]
isDec :: Char -> Bool
isDec :: Char -> Bool
isDec Char
c = Char
c forall a. Ord a => a -> a -> Bool
>= Char
'0' Bool -> Bool -> Bool
&& Char
c 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 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
"\\&" forall a. [a] -> [a] -> [a]
++ String
s
cont String
s = String
s
asciiTab :: [String]
asciiTab :: [String]
asciiTab =
[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"]
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' 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' forall a. Num a => a -> a -> a
+ Int# -> Int
I# Int#
i forall a. Num a => a -> a -> a
- Int
10)
| Bool
otherwise = forall a. String -> a
errorWithoutStackTrace (String
"Char.intToDigit: not a digit " forall a. [a] -> [a] -> [a]
++ 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
'(' forall a. a -> [a] -> [a]
: Int# -> ShowS
itos Int#
n (Char
')' 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#)
then Char
'-' 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
'-' 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#)) 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# forall a. a -> [a] -> [a]
: String
cs')
instance Show Integer where
showsPrec :: Int -> Integer -> ShowS
showsPrec Int
p (IS Int#
i) String
r = 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 forall a. Ord a => a -> a -> Bool
> Int
6 Bool -> Bool -> Bool
&& Integer
n forall a. Ord a => a -> a -> Bool
< Integer
0 = Char
'(' forall a. a -> [a] -> [a]
: Integer -> ShowS
integerToString Integer
n (Char
')' forall a. a -> [a] -> [a]
: String
r)
| Bool
otherwise = Integer -> ShowS
integerToString Integer
n String
r
showList :: [Integer] -> ShowS
showList = forall a. (a -> ShowS) -> [a] -> ShowS
showList__ (forall a. Show a => Int -> a -> ShowS
showsPrec Int
0)
instance Show Natural where
showsPrec :: Int -> Natural -> ShowS
showsPrec Int
p (NS Word#
w) = forall a. Show a => Int -> a -> ShowS
showsPrec Int
p (Word# -> Word
W# Word#
w)
showsPrec Int
p Natural
n = forall a. Show a => Int -> a -> ShowS
showsPrec Int
p (Natural -> Integer
integerFromNatural Natural
n)
integerToString :: Integer -> String -> String
integerToString :: Integer -> ShowS
integerToString Integer
n0 String
cs0
| Integer
n0 forall a. Ord a => a -> a -> Bool
< Integer
0 = Char
'-' 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 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 Integer
p Integer
n
| Integer
p forall a. Ord a => a -> a -> Bool
> Integer
n = [Integer
n]
| Bool
otherwise = Integer -> [Integer] -> [Integer]
jsplith Integer
p (Integer -> Integer -> [Integer]
jsplitf (Integer
pforall 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 forall a. Ord a => a -> a -> Bool
> Integer
0 then Integer
q forall a. a -> [a] -> [a]
: Integer
r forall a. a -> [a] -> [a]
: Integer -> [Integer] -> [Integer]
jsplitb Integer
p [Integer]
ns
else Integer
r forall a. a -> [a] -> [a]
: Integer -> [Integer] -> [Integer]
jsplitb Integer
p [Integer]
ns
jsplith 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 forall a. a -> [a] -> [a]
: Integer
r forall a. a -> [a] -> [a]
: Integer -> [Integer] -> [Integer]
jsplitb Integer
p [Integer]
ns
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 = forall a. Num a => Integer -> a
fromInteger Integer
q'
r :: Int
r = forall a. Num a => Integer -> a
fromInteger Integer
r'
in if Int
q forall a. Ord a => a -> a -> Bool
> Int
0 then Int -> ShowS
jhead Int
q forall a b. (a -> b) -> a -> b
$ Int -> ShowS
jblock Int
r forall a b. (a -> b) -> a -> b
$ [Integer] -> ShowS
jprintb [Integer]
ns String
cs
else Int -> ShowS
jhead Int
r forall a b. (a -> b) -> a -> b
$ [Integer] -> ShowS
jprintb [Integer]
ns String
cs
jprinth [] String
_ = 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 = forall a. Num a => Integer -> a
fromInteger Integer
q'
r :: Int
r = forall a. Num a => Integer -> a
fromInteger Integer
r'
in Int -> ShowS
jblock Int
q forall a b. (a -> b) -> a -> b
$ Int -> ShowS
jblock Int
r forall a b. (a -> b) -> a -> b
$ [Integer] -> ShowS
jprintb [Integer]
ns String
cs
jhead :: Int -> String -> String
jhead :: Int -> ShowS
jhead Int
n String
cs
| Int
n forall a. Ord a => a -> a -> Bool
< Int
10 = case Int -> Char
unsafeChr (Char -> Int
ord Char
'0' forall a. Num a => a -> a -> a
+ Int
n) of
c :: Char
c@(C# Char#
_) -> Char
c forall a. a -> [a] -> [a]
: String
cs
| Bool
otherwise = case Int -> Char
unsafeChr (Char -> Int
ord Char
'0' forall a. Num a => a -> a -> a
+ Int
r) of
c :: Char
c@(C# Char#
_) -> Int -> ShowS
jhead Int
q (Char
c 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 forall a. Eq a => a -> a -> Bool
== Int
1 = case Int -> Char
unsafeChr (Char -> Int
ord Char
'0' forall a. Num a => a -> a -> a
+ Int
n) of
c :: Char
c@(C# Char#
_) -> Char
c forall a. a -> [a] -> [a]
: String
cs
| Bool
otherwise = case Int -> Char
unsafeChr (Char -> Int
ord Char
'0' forall a. Num a => a -> a -> a
+ Int
r) of
c :: Char
c@(C# Char#
_) -> Int -> Int -> ShowS
jblock' (Int
d forall a. Num a => a -> a -> a
- Int
1) Int
q (Char
c 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 forall a. Ord a => a -> a -> Bool
> Int
10) forall a b. (a -> b) -> a -> b
$
String -> ShowS
showString String
"KindRepVar " forall b c a. (b -> c) -> (a -> b) -> a -> c
. 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 forall a. Ord a => a -> a -> Bool
> Int
10) forall a b. (a -> b) -> a -> b
$
String -> ShowS
showString String
"KindRepTyConApp "
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Show a => Int -> a -> ShowS
showsPrec Int
11 TyCon
p
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
" "
forall b c a. (b -> c) -> (a -> b) -> a -> c
. 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 forall a. Ord a => a -> a -> Bool
> Int
10) forall a b. (a -> b) -> a -> b
$
String -> ShowS
showString String
"KindRepApp "
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Show a => Int -> a -> ShowS
showsPrec Int
11 KindRep
p
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
" "
forall b c a. (b -> c) -> (a -> b) -> a -> c
. 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 forall a. Ord a => a -> a -> Bool
> Int
10) forall a b. (a -> b) -> a -> b
$
String -> ShowS
showString String
"KindRepFun "
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Show a => Int -> a -> ShowS
showsPrec Int
11 KindRep
p
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
" "
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Show a => Int -> a -> ShowS
showsPrec Int
11 KindRep
q
showsPrec Int
d (KindRepTYPE RuntimeRep
rep) = Bool -> ShowS -> ShowS
showParen (Int
d forall a. Ord a => a -> a -> Bool
> Int
10) forall a b. (a -> b) -> a -> b
$
String -> ShowS
showString String
"KindRepTYPE " forall b c a. (b -> c) -> (a -> b) -> a -> c
. 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 forall a. Ord a => a -> a -> Bool
> Int
10) forall a b. (a -> b) -> a -> b
$
String -> ShowS
showString String
"KindRepTypeLitS "
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Show a => Int -> a -> ShowS
showsPrec Int
11 TypeLitSort
p
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
" "
forall b c a. (b -> c) -> (a -> b) -> a -> c
. 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 forall a. Ord a => a -> a -> Bool
> Int
10) forall a b. (a -> b) -> a -> b
$
String -> ShowS
showString String
"KindRepTypeLitD "
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Show a => Int -> a -> ShowS
showsPrec Int
11 TypeLitSort
p
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
" "
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Show a => Int -> a -> ShowS
showsPrec Int
11 String
q
deriving instance Show Levity
deriving instance Show RuntimeRep
deriving instance Show VecCount
deriving instance Show VecElem
deriving instance Show TypeLitSort