module TextShow.Data.Functor.Trans (
showbComposePrecWith
, showbConstantPrecWith
, showbProductPrecWith
, showbReversePrecWith
, showbSumPrecWith
) where
import Data.Functor.Compose (Compose(..))
import Data.Functor.Constant (Constant(..))
import Data.Functor.Product (Product(..))
import Data.Functor.Reverse (Reverse(..))
import Data.Functor.Sum (Sum(..))
import TextShow (TextShow(showbPrec), TextShow1(..), TextShow2(..),
Builder, showbPrec1, showbUnaryWith, showbBinaryWith)
#include "inline.h"
showbComposePrecWith :: (TextShow1 f, TextShow1 g)
=> (Int -> a -> Builder)
-> Int -> Compose f g a -> Builder
showbComposePrecWith sp p (Compose x) =
showbUnaryWith (showbPrecWith (showbPrecWith sp)) "Compose" p x
showbConstantPrecWith :: (Int -> a -> Builder) -> Int -> Constant a b -> Builder
showbConstantPrecWith sp p (Constant x) = showbUnaryWith sp "Constant" p x
showbProductPrecWith :: (TextShow1 f, TextShow1 g)
=> (Int -> a -> Builder)
-> Int -> Product f g a -> Builder
showbProductPrecWith sp p (Pair x y) =
showbBinaryWith (showbPrecWith sp) (showbPrecWith sp) "Pair" p x y
showbReversePrecWith :: TextShow1 f
=> (Int -> a -> Builder)
-> Int -> Reverse f a -> Builder
showbReversePrecWith sp p (Reverse x) = showbUnaryWith (showbPrecWith sp) "Reverse" p x
showbSumPrecWith :: (TextShow1 f, TextShow1 g)
=> (Int -> a -> Builder)
-> Int -> Sum f g a -> Builder
showbSumPrecWith sp p (InL x) = showbUnaryWith (showbPrecWith sp) "InL" p x
showbSumPrecWith sp p (InR y) = showbUnaryWith (showbPrecWith sp) "InR" p y
instance (TextShow1 f, TextShow1 g, TextShow a) => TextShow (Compose f g a) where
showbPrec = showbPrec1
INLINE_INST_FUN(showbPrec)
instance (TextShow1 f, TextShow1 g) => TextShow1 (Compose f g) where
showbPrecWith = showbComposePrecWith
INLINE_INST_FUN(showbPrecWith)
instance TextShow a => TextShow (Constant a b) where
showbPrec = showbConstantPrecWith showbPrec
INLINE_INST_FUN(showbPrec)
instance TextShow a => TextShow1 (Constant a) where
showbPrecWith = showbPrecWith2 showbPrec
INLINE_INST_FUN(showbPrecWith)
instance TextShow2 Constant where
showbPrecWith2 sp _ = showbConstantPrecWith sp
INLINE_INST_FUN(showbPrecWith2)
instance (TextShow1 f, TextShow1 g, TextShow a) => TextShow (Product f g a) where
showbPrec = showbPrec1
INLINE_INST_FUN(showbPrec)
instance (TextShow1 f, TextShow1 g) => TextShow1 (Product f g) where
showbPrecWith = showbProductPrecWith
INLINE_INST_FUN(showbPrecWith)
instance (TextShow1 f, TextShow a) => TextShow (Reverse f a) where
showbPrec = showbPrec1
INLINE_INST_FUN(showbPrec)
instance TextShow1 f => TextShow1 (Reverse f) where
showbPrecWith = showbReversePrecWith
INLINE_INST_FUN(showbPrecWith)
instance (TextShow1 f, TextShow1 g, TextShow a) => TextShow (Sum f g a) where
showbPrec = showbPrec1
INLINE_INST_FUN(showbPrec)
instance (TextShow1 f, TextShow1 g) => TextShow1 (Sum f g) where
showbPrecWith = showbSumPrecWith
INLINE_INST_FUN(showbPrecWith)