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 con :: String
con _ = String -> ShowS
showString String
con
infixl 2 `showApp`, @|
showApp :: PrecShowS -> PrecShowS -> PrecShowS
showApp :: PrecShowS -> PrecShowS -> PrecShowS
showApp showF :: PrecShowS
showF showX :: PrecShowS
showX d :: 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
(@|) showF :: PrecShowS
showF x :: 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 op :: String
op prec :: 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
+ 1) (Int
prec Int -> Int -> Int
forall a. Num a => a -> a -> a
+ 1)
showInfix' :: (Show a, Show b) => String -> Int -> a -> b -> PrecShowS
showInfix' :: String -> Int -> a -> b -> PrecShowS
showInfix' op :: String
op prec :: Int
prec x :: a
x y :: 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 op :: String
op prec :: 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
+ 1)
showInfixl' :: (Show a, Show b) => String -> Int -> a -> b -> PrecShowS
showInfixl' :: String -> Int -> a -> b -> PrecShowS
showInfixl' op :: String
op prec :: Int
prec x :: a
x y :: 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 op :: String
op prec :: 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
+ 1) Int
prec
showInfixr' :: (Show a, Show b) => String -> Int -> a -> b -> PrecShowS
showInfixr' :: String -> Int -> a -> b -> PrecShowS
showInfixr' op :: String
op prec :: Int
prec x :: a
x y :: 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_ op :: String
op prec :: Int
prec precX :: Int
precX precY :: Int
precY showX :: PrecShowS
showX showY :: PrecShowS
showY d :: 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 con :: String
con showFields :: ShowS
showFields d :: 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 '{' 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 '}')
showField :: String -> PrecShowS -> ShowFields
showField :: String -> PrecShowS -> ShowS
showField field :: String
field showX :: PrecShowS
showX =
String -> ShowS
showString String
field 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
. PrecShowS
showX 0
infixr 8 .=.
(.=.) :: Show a => String -> a -> ShowFields
field :: String
field .=. :: String -> a -> ShowS
.=. x :: 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 showFds1 :: ShowS
showFds1 showFds2 :: ShowS
showFds2 = ShowS
showFds1 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
. ShowS
showFds2
(&|) :: ShowFields -> ShowFields -> ShowFields
&| :: ShowS -> ShowS -> ShowS
(&|) = ShowS -> ShowS -> ShowS
appendFields
showSpace :: ShowS
showSpace :: ShowS
showSpace = (' ' Char -> ShowS
forall a. a -> [a] -> [a]
:)
appPrec, appPrec1 :: Int
appPrec :: Int
appPrec = 10
appPrec1 :: Int
appPrec1 = 11