module TextShow.GHC.Generics (
showbU1
, showbPar1PrecWith
, showbRec1Prec
, showbRec1PrecWith
, showbK1PrecWith
, showbM1Prec
, showbM1PrecWith
, showbSumTypePrec
, showbSumTypePrecWith
, showbProductTypePrec
, showbProductTypePrecWith
, showbCompFunctorsPrec
, showbCompFunctorsPrecWith
, showbFixityPrec
, showbAssociativity
, showbArityPrec
, showbUCharPrec
, showbUDoublePrec
, showbUFloatPrec
, showbUIntPrec
, showbUWordPrec
) where
import Data.Text.Lazy.Builder (Builder)
import Generics.Deriving.Base
import TextShow.Classes (TextShow(showb, showbPrec), TextShow1(..), TextShow2(..))
import TextShow.Data.Char ()
import TextShow.Data.Floating ()
import TextShow.Data.Integral ()
import TextShow.TH.Internal (deriveTextShow, deriveTextShow1, makeShowbPrec,
makeShowbPrecWith, makeShowbPrecWith2)
#if !(MIN_VERSION_template_haskell(2,7,0))
import Data.Monoid.Compat ((<>))
import Data.Text.Lazy.Builder (fromString, singleton)
import GHC.Exts (Char(C#), Double(D#), Float(F#), Int(I#), Word(W#))
import GHC.Show (appPrec)
import TextShow.Classes (showbParen)
#endif
showbU1 :: U1 p -> Builder
showbU1 = showb
showbPar1PrecWith :: (Int -> p -> Builder) -> Int -> Par1 p -> Builder
showbPar1PrecWith = showbPrecWith
showbRec1Prec :: TextShow (f p) => Int -> Rec1 f p -> Builder
showbRec1Prec = showbPrec
showbRec1PrecWith :: TextShow1 f => (Int -> p -> Builder) -> Int -> Rec1 f p -> Builder
showbRec1PrecWith = showbPrecWith
showbK1PrecWith :: (Int -> c -> Builder) -> Int -> K1 i c p -> Builder
showbK1PrecWith sp = showbPrecWith2 sp undefined
showbM1Prec :: TextShow (f p) => Int -> M1 i c f p -> Builder
showbM1Prec = showbPrec
showbM1PrecWith :: TextShow1 f => (Int -> p -> Builder) -> Int -> M1 i c f p -> Builder
showbM1PrecWith = showbPrecWith
showbSumTypePrec :: (TextShow (f p), TextShow (g p)) => Int -> (f :+: g) p -> Builder
showbSumTypePrec = showbPrec
showbSumTypePrecWith :: (TextShow1 f, TextShow1 g) => (Int -> p -> Builder) -> Int -> (f :+: g) p -> Builder
showbSumTypePrecWith = showbPrecWith
showbProductTypePrec :: (TextShow (f p), TextShow (g p)) => Int -> (f :*: g) p -> Builder
showbProductTypePrec = showbPrec
showbProductTypePrecWith :: (TextShow1 f, TextShow1 g) => (Int -> p -> Builder) -> Int -> (f :*: g) p -> Builder
showbProductTypePrecWith = showbPrecWith
showbCompFunctorsPrec :: TextShow (f (g p)) => Int -> (f :.: g) p -> Builder
showbCompFunctorsPrec = showbPrec
showbCompFunctorsPrecWith :: (TextShow1 f, TextShow1 g) => (Int -> p -> Builder) -> Int -> (f :.: g) p -> Builder
showbCompFunctorsPrecWith = showbPrecWith
showbFixityPrec :: Int -> Fixity -> Builder
showbFixityPrec = showbPrec
showbAssociativity :: Associativity -> Builder
showbAssociativity = showb
showbArityPrec :: Int -> Arity -> Builder
showbArityPrec = showbPrec
showbUCharPrec :: Int -> UChar p -> Builder
showbUCharPrec = showbPrec
showbUDoublePrec :: Int -> UDouble p -> Builder
showbUDoublePrec = showbPrec
showbUFloatPrec :: Int -> UFloat p -> Builder
showbUFloatPrec = showbPrec
showbUIntPrec :: Int -> UInt p -> Builder
showbUIntPrec = showbPrec
showbUWordPrec :: Int -> UWord p -> Builder
showbUWordPrec = showbPrec
instance TextShow (U1 p) where
showbPrec = showbPrecWith undefined
$(deriveTextShow1 ''U1)
$(deriveTextShow ''Par1)
$(deriveTextShow1 ''Par1)
instance TextShow (f p) => TextShow (Rec1 f p) where
showbPrec = $(makeShowbPrec ''Rec1)
$(deriveTextShow1 ''Rec1)
instance TextShow c => TextShow (K1 i c p) where
showbPrec = showbPrecWith undefined
instance TextShow c => TextShow1 (K1 i c) where
showbPrecWith = showbPrecWith2 showbPrec
instance TextShow2 (K1 i) where
showbPrecWith2 = $(makeShowbPrecWith2 ''K1)
instance TextShow (f p) => TextShow (M1 i c f p) where
showbPrec = $(makeShowbPrec ''M1)
instance TextShow1 f => TextShow1 (M1 i c f) where
showbPrecWith = $(makeShowbPrecWith ''M1)
instance (TextShow (f p), TextShow (g p)) => TextShow ((f :+: g) p) where
showbPrec = $(makeShowbPrec ''(:+:))
$(deriveTextShow1 ''(:+:))
instance (TextShow (f p), TextShow (g p)) => TextShow ((f :*: g) p) where
showbPrec = $(makeShowbPrec ''(:*:))
$(deriveTextShow1 ''(:*:))
instance TextShow (f (g p)) => TextShow ((f :.: g) p) where
showbPrec = $(makeShowbPrec ''(:.:))
$(deriveTextShow1 ''(:.:))
#if MIN_VERSION_template_haskell(2,7,0)
instance TextShow (UChar p) where
showbPrec = $(makeShowbPrec 'UChar)
$(deriveTextShow1 'UChar)
instance TextShow (UDouble p) where
showbPrec = $(makeShowbPrec 'UDouble)
$(deriveTextShow1 'UDouble)
instance TextShow (UFloat p) where
showbPrec = $(makeShowbPrec 'UFloat)
$(deriveTextShow1 'UFloat)
instance TextShow (UInt p) where
showbPrec = $(makeShowbPrec 'UInt)
$(deriveTextShow1 'UInt)
instance TextShow (UWord p) where
showbPrec = $(makeShowbPrec 'UWord)
$(deriveTextShow1 'UWord)
#else
instance TextShow (UChar p) where
showbPrec = showbPrecWith undefined
instance TextShow1 UChar where
showbPrecWith _ p (UChar c) = showbParen (p > appPrec) $
fromString "UChar " <> singleton '{'
<> fromString "uChar# = " <> showb (C# c)
<> singleton '}'
instance TextShow (UDouble p) where
showbPrec = showbPrecWith undefined
instance TextShow1 UDouble where
showbPrecWith _ p (UDouble d) = showbParen (p > appPrec) $
fromString "UDouble " <> singleton '{'
<> fromString "uDouble# = " <> showb (D# d)
<> singleton '}'
instance TextShow (UFloat p) where
showbPrec = showbPrecWith undefined
instance TextShow1 UFloat where
showbPrecWith _ p (UFloat f) = showbParen (p > appPrec) $
fromString "UFloat " <> singleton '{'
<> fromString "uFloat# = " <> showb (F# f)
<> singleton '}'
instance TextShow (UInt p) where
showbPrec = showbPrecWith undefined
instance TextShow1 UInt where
showbPrecWith _ p (UInt i) = showbParen (p > appPrec) $
fromString "UInt " <> singleton '{'
<> fromString "uInt# = " <> showb (I# i)
<> singleton '}'
instance TextShow (UWord p) where
showbPrec = showbPrecWith undefined
instance TextShow1 UWord where
showbPrecWith _ p (UWord w) = showbParen (p > appPrec) $
fromString "UWord " <> singleton '{'
<> fromString "uWord# = " <> showb (W# w)
<> singleton '}'
#endif
$(deriveTextShow ''Fixity)
$(deriveTextShow ''Associativity)
$(deriveTextShow ''Arity)