{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PolyKinds #-}
{-# OPTIONS_GHC -Wno-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 :: forall {k} a (b :: k).
(Int -> a -> Builder) -> Int -> Constant a b -> Builder
liftShowbConstantPrec Int -> a -> Builder
sp Int
p (Constant a
x) = forall a. (Int -> a -> Builder) -> Builder -> Int -> a -> Builder
showbUnaryWith Int -> a -> Builder
sp Builder
"Constant" Int
p a
x
{-# INLINE liftShowbConstantPrec #-}
instance TextShow a => TextShow (Constant a b) where
showbPrec :: Int -> Constant a b -> Builder
showbPrec = forall {k} a (b :: k).
(Int -> a -> Builder) -> Int -> Constant a b -> Builder
liftShowbConstantPrec forall a. TextShow a => Int -> a -> Builder
showbPrec
{-# INLINE showbPrec #-}
instance TextShow a => TextShow1 (Constant a) where
liftShowbPrec :: forall a.
(Int -> a -> Builder)
-> ([a] -> Builder) -> Int -> Constant a a -> Builder
liftShowbPrec Int -> a -> Builder
_ [a] -> Builder
_ = forall {k} a (b :: k).
(Int -> a -> Builder) -> Int -> Constant a b -> Builder
liftShowbConstantPrec forall a. TextShow a => Int -> a -> Builder
showbPrec
{-# INLINE liftShowbPrec #-}
instance TextShow2 Constant where
liftShowbPrec2 :: forall a b.
(Int -> a -> Builder)
-> ([a] -> Builder)
-> (Int -> b -> Builder)
-> ([b] -> Builder)
-> Int
-> Constant a b
-> Builder
liftShowbPrec2 Int -> a -> Builder
sp [a] -> Builder
_ Int -> b -> Builder
_ [b] -> Builder
_ = forall {k} a (b :: k).
(Int -> a -> Builder) -> Int -> Constant a b -> Builder
liftShowbConstantPrec Int -> a -> Builder
sp
{-# INLINE liftShowbPrec2 #-}
instance (TextShow1 f, TextShow a) => TextShow (Reverse f a) where
showbPrec :: Int -> Reverse f a -> Builder
showbPrec = forall (f :: * -> *) a.
(TextShow1 f, TextShow a) =>
Int -> f a -> Builder
showbPrec1
{-# INLINE showbPrec #-}
instance TextShow1 f => TextShow1 (Reverse f) where
liftShowbPrec :: forall a.
(Int -> a -> Builder)
-> ([a] -> Builder) -> Int -> Reverse f a -> Builder
liftShowbPrec Int -> a -> Builder
sp [a] -> Builder
sl Int
p (Reverse f a
x) = forall (m :: * -> *) a.
TextShow1 m =>
(Int -> a -> Builder)
-> ([a] -> Builder) -> Builder -> Int -> m a -> Builder
liftShowbUnaryWith Int -> a -> Builder
sp [a] -> Builder
sl Builder
"Reverse" Int
p f a
x
{-# INLINE liftShowbPrec #-}