{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-}
#if __GLASGOW_HASKELL__ >= 706
{-# LANGUAGE PolyKinds #-}
#endif
{-# OPTIONS_GHC -fno-warn-orphans #-}
module TextShow.Data.Functor.Trans () where
import Data.Functor.Constant (Constant(..))
import Data.Functor.Reverse (Reverse(..))
import TextShow (TextShow(..), TextShow1(..), TextShow2(..),
Builder, showbPrec1, showbUnaryWith)
import TextShow.Utils (liftShowbUnaryWith)
liftShowbConstantPrec :: (Int -> a -> Builder) -> Int -> Constant a b -> Builder
liftShowbConstantPrec sp p (Constant x) = showbUnaryWith sp "Constant" p x
{-# INLINE liftShowbConstantPrec #-}
instance TextShow a => TextShow (Constant a b) where
showbPrec = liftShowbConstantPrec showbPrec
{-# INLINE showbPrec #-}
instance TextShow a => TextShow1 (Constant a) where
liftShowbPrec _ _ = liftShowbConstantPrec showbPrec
{-# INLINE liftShowbPrec #-}
instance TextShow2 Constant where
liftShowbPrec2 sp _ _ _ = liftShowbConstantPrec sp
{-# INLINE liftShowbPrec2 #-}
instance (TextShow1 f, TextShow a) => TextShow (Reverse f a) where
showbPrec = showbPrec1
{-# INLINE showbPrec #-}
instance TextShow1 f => TextShow1 (Reverse f) where
liftShowbPrec sp sl p (Reverse x) = liftShowbUnaryWith sp sl "Reverse" p x
{-# INLINE liftShowbPrec #-}