#if !(MIN_VERSION_bytestring(0,10,0))
#endif
module Text.Show.Text.Data.ByteString (
showbByteStringStrict
, showbByteStringLazy
, showbByteStringLazyPrec
#if MIN_VERSION_bytestring(0,10,4)
, showbShortByteString
#endif
) where
import qualified Data.ByteString as BS
import qualified Data.ByteString.Lazy as BL
#if MIN_VERSION_bytestring(0,10,4)
import Data.ByteString.Short (ShortByteString)
#endif
import Data.Text.Lazy.Builder (Builder, fromString)
import qualified Prelude as P
import Prelude hiding (Show(show))
import Text.Show.Text.Class (Show(showb, showbPrec))
#if !(MIN_VERSION_bytestring(0,10,0))
import qualified Data.ByteString.Lazy.Internal as BL
import GHC.Show (appPrec, appPrec1)
import Text.Show.Text.Class (showbParen)
import Text.Show.Text.Utils ((<>), s)
#endif
showbByteStringStrict :: BS.ByteString -> Builder
showbByteStringStrict = fromString . P.show
showbByteStringLazy :: BL.ByteString -> Builder
showbByteStringLazy = showbByteStringLazyPrec 0
showbByteStringLazyPrec :: Int -> BL.ByteString -> Builder
#if MIN_VERSION_bytestring(0,10,0)
showbByteStringLazyPrec _ = fromString . P.show
#else
showbByteStringLazyPrec _ BL.Empty = "Empty"
showbByteStringLazyPrec p (BL.Chunk bs bl) = showbParen (p > appPrec) $
"Chunk "
<> showbPrec appPrec1 bs
<> s ' '
<> showbPrec appPrec1 bl
#endif
#if MIN_VERSION_bytestring(0,10,4)
showbShortByteString :: ShortByteString -> Builder
showbShortByteString = fromString . P.show
#endif
instance Show BS.ByteString where
showb = showbByteStringStrict
instance Show BL.ByteString where
showbPrec = showbByteStringLazyPrec
#if MIN_VERSION_bytestring(0,10,4)
instance Show ShortByteString where
showb = showbShortByteString
#endif