module Text.Show.Combinators
( module Text.Show
, PrecShowS
, showCon
, showApp
, (@|)
, showInfix
, showInfix'
, showInfixl
, showInfixl'
, showInfixr
, showInfixr'
, ShowFields
, showRecord
, showField
, (.=.)
, noFields
, appendFields
, (&|)
) where
import Text.Show
type PrecShowS = Int -> ShowS
showCon :: String -> PrecShowS
showCon :: String -> PrecShowS
showCon String
con Int
_ = String -> ShowS
showString String
con
infixl 2 `showApp`, @|
showApp :: PrecShowS -> PrecShowS -> PrecShowS
showApp :: PrecShowS -> PrecShowS -> PrecShowS
showApp PrecShowS
showF PrecShowS
showX Int
d = Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
appPrec)
(PrecShowS
showF Int
appPrec ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShowS
showSpace ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrecShowS
showX Int
appPrec1)
(@|) :: Show a => PrecShowS -> a -> PrecShowS
@| :: PrecShowS -> a -> PrecShowS
(@|) PrecShowS
showF a
x = PrecShowS -> PrecShowS -> PrecShowS
showApp PrecShowS
showF ((Int -> a -> ShowS) -> a -> PrecShowS
forall a b c. (a -> b -> c) -> b -> a -> c
flip Int -> a -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec a
x)
showInfix :: String -> Int -> PrecShowS -> PrecShowS -> PrecShowS
showInfix :: String -> Int -> PrecShowS -> PrecShowS -> PrecShowS
showInfix String
op Int
prec = String -> Int -> Int -> Int -> PrecShowS -> PrecShowS -> PrecShowS
showInfix_ String
op Int
prec (Int
prec Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1) (Int
prec Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1)
showInfix' :: (Show a, Show b) => String -> Int -> a -> b -> PrecShowS
showInfix' :: String -> Int -> a -> b -> PrecShowS
showInfix' String
op Int
prec a
x b
y = String -> Int -> PrecShowS -> PrecShowS -> PrecShowS
showInfix String
op Int
prec ((Int -> a -> ShowS) -> a -> PrecShowS
forall a b c. (a -> b -> c) -> b -> a -> c
flip Int -> a -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec a
x) ((Int -> b -> ShowS) -> b -> PrecShowS
forall a b c. (a -> b -> c) -> b -> a -> c
flip Int -> b -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec b
y)
showInfixl :: String -> Int -> PrecShowS -> PrecShowS -> PrecShowS
showInfixl :: String -> Int -> PrecShowS -> PrecShowS -> PrecShowS
showInfixl String
op Int
prec = String -> Int -> Int -> Int -> PrecShowS -> PrecShowS -> PrecShowS
showInfix_ String
op Int
prec Int
prec (Int
prec Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1)
showInfixl' :: (Show a, Show b) => String -> Int -> a -> b -> PrecShowS
showInfixl' :: String -> Int -> a -> b -> PrecShowS
showInfixl' String
op Int
prec a
x b
y = String -> Int -> PrecShowS -> PrecShowS -> PrecShowS
showInfixl String
op Int
prec ((Int -> a -> ShowS) -> a -> PrecShowS
forall a b c. (a -> b -> c) -> b -> a -> c
flip Int -> a -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec a
x) ((Int -> b -> ShowS) -> b -> PrecShowS
forall a b c. (a -> b -> c) -> b -> a -> c
flip Int -> b -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec b
y)
showInfixr :: String -> Int -> PrecShowS -> PrecShowS -> PrecShowS
showInfixr :: String -> Int -> PrecShowS -> PrecShowS -> PrecShowS
showInfixr String
op Int
prec = String -> Int -> Int -> Int -> PrecShowS -> PrecShowS -> PrecShowS
showInfix_ String
op Int
prec (Int
prec Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1) Int
prec
showInfixr' :: (Show a, Show b) => String -> Int -> a -> b -> PrecShowS
showInfixr' :: String -> Int -> a -> b -> PrecShowS
showInfixr' String
op Int
prec a
x b
y = String -> Int -> PrecShowS -> PrecShowS -> PrecShowS
showInfixr String
op Int
prec ((Int -> a -> ShowS) -> a -> PrecShowS
forall a b c. (a -> b -> c) -> b -> a -> c
flip Int -> a -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec a
x) ((Int -> b -> ShowS) -> b -> PrecShowS
forall a b c. (a -> b -> c) -> b -> a -> c
flip Int -> b -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec b
y)
showInfix_ :: String -> Int -> Int -> Int -> PrecShowS -> PrecShowS -> PrecShowS
showInfix_ :: String -> Int -> Int -> Int -> PrecShowS -> PrecShowS -> PrecShowS
showInfix_ String
op Int
prec Int
precX Int
precY PrecShowS
showX PrecShowS
showY Int
d = Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
prec)
(PrecShowS
showX Int
precX ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShowS
showSpace ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
op ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShowS
showSpace ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrecShowS
showY Int
precY)
type ShowFields = ShowS
showRecord :: String -> ShowFields -> PrecShowS
showRecord :: String -> ShowS -> PrecShowS
showRecord String
con ShowS
showFields Int
d = Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
appPrec)
(String -> ShowS
showString String
con ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShowS
showSpace 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
showFields ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> ShowS
showChar Char
'}')
showField :: String -> PrecShowS -> ShowFields
showField :: String -> PrecShowS -> ShowS
showField String
field PrecShowS
showX =
String -> ShowS
showString String
field 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
. PrecShowS
showX Int
0
infixr 8 .=.
(.=.) :: Show a => String -> a -> ShowFields
String
field .=. :: String -> a -> ShowS
.=. a
x = String -> PrecShowS -> ShowS
showField String
field ((Int -> a -> ShowS) -> a -> PrecShowS
forall a b c. (a -> b -> c) -> b -> a -> c
flip Int -> a -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec a
x)
noFields :: ShowFields
noFields :: ShowS
noFields = ShowS
forall a. a -> a
id
infixr 1 `appendFields`, &|
appendFields :: ShowFields -> ShowFields -> ShowFields
appendFields :: ShowS -> ShowS -> ShowS
appendFields ShowS
showFds1 ShowS
showFds2 = ShowS
showFds1 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
. ShowS
showFds2
(&|) :: ShowFields -> ShowFields -> ShowFields
&| :: ShowS -> ShowS -> ShowS
(&|) = ShowS -> ShowS -> ShowS
appendFields
showSpace :: ShowS
showSpace :: ShowS
showSpace = (Char
' ' Char -> ShowS
forall a. a -> [a] -> [a]
:)
appPrec, appPrec1 :: Int
appPrec :: Int
appPrec = Int
10
appPrec1 :: Int
appPrec1 = Int
11