module Text.Show.Text.Data.Monoid (
showbAllPrec
, showbAnyPrec
, showbDualPrec
, showbFirstPrec
, showbLastPrec
, showbProductPrec
, showbSumPrec
) where
import Data.Monoid (All(..), Any(..), Dual(..), First(..),
Last(..), Product(..), Sum(..))
import Data.Text.Lazy.Builder (Builder)
import GHC.Show (appPrec)
import Prelude hiding (Show)
import Text.Show.Text.Class (Show(showb, showbPrec), showbParen)
import Text.Show.Text.Data.Bool (showbBool)
import Text.Show.Text.Data.Maybe (showbMaybePrec)
import Text.Show.Text.Utils ((<>), s)
showbAllPrec :: Int -> All -> Builder
showbAllPrec p (All a) = showbParen (p > appPrec) $
"All {getAll = "
<> showbBool a
<> s '}'
showbAnyPrec :: Int -> Any -> Builder
showbAnyPrec p (Any a) = showbParen (p > appPrec) $
"Any {getAny = "
<> showbBool a
<> s '}'
showbDualPrec :: Show a => Int -> Dual a -> Builder
showbDualPrec p (Dual d) = showbParen (p > appPrec) $
"Dual {getDual = "
<> showb d
<> s '}'
showbFirstPrec :: Show a => Int -> First a -> Builder
showbFirstPrec p (First f) = showbParen (p > appPrec) $
"First {getFirst = "
<> showbMaybePrec 0 f
<> s '}'
showbLastPrec :: Show a => Int -> Last a -> Builder
showbLastPrec p (Last l) = showbParen (p > appPrec) $
"Last {getLast = "
<> showbMaybePrec 0 l
<> s '}'
showbProductPrec :: Show a => Int -> Product a -> Builder
showbProductPrec p (Product prod) = showbParen (p > appPrec) $
"Product {getProduct = "
<> showb prod
<> s '}'
showbSumPrec :: Show a => Int -> Sum a -> Builder
showbSumPrec p (Sum sum') = showbParen (p > appPrec) $
"Sum {getSum = "
<> showb sum'
<> s '}'
instance Show All where
showbPrec = showbAllPrec
instance Show Any where
showbPrec = showbAnyPrec
instance Show a => Show (Dual a) where
showbPrec = showbDualPrec
instance Show a => Show (First a) where
showbPrec = showbFirstPrec
instance Show a => Show (Last a) where
showbPrec = showbLastPrec
instance Show a => Show (Product a) where
showbPrec = showbProductPrec
instance Show a => Show (Sum a) where
showbPrec = showbSumPrec