{-# LANGUAGE OverloadedStrings #-}
{-# OPTIONS_GHC -Wno-orphans #-}
module TextShow.Data.Binary () where
import Data.Binary.Get.Internal (Decoder(..))
import Prelude ()
import Prelude.Compat
import TextShow (TextShow(..), TextShow1(..), Builder, fromString, showbPrec1)
instance TextShow a => TextShow (Decoder a) where
showbPrec :: Int -> Decoder a -> Builder
showbPrec = Int -> Decoder a -> Builder
forall (f :: * -> *) a.
(TextShow1 f, TextShow a) =>
Int -> f a -> Builder
showbPrec1
{-# INLINE showbPrec #-}
instance TextShow1 Decoder where
liftShowbPrec :: forall a.
(Int -> a -> Builder)
-> ([a] -> Builder) -> Int -> Decoder a -> Builder
liftShowbPrec Int -> a -> Builder
sp' [a] -> Builder
_ Int
_ = (a -> Builder) -> Decoder a -> Builder
forall a. (a -> Builder) -> Decoder a -> Builder
go ((a -> Builder) -> Decoder a -> Builder)
-> (a -> Builder) -> Decoder a -> Builder
forall a b. (a -> b) -> a -> b
$ Int -> a -> Builder
sp' Int
0
where
go :: (a -> Builder) -> Decoder a -> Builder
go :: forall a. (a -> Builder) -> Decoder a -> Builder
go a -> Builder
_ (Fail ByteString
_ String
msg) = Builder
"Fail: " Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> String -> Builder
fromString String
msg
go a -> Builder
_ (Partial Maybe ByteString -> Decoder a
_) = Builder
"Partial _"
go a -> Builder
sp (Done ByteString
_ a
a) = Builder
"Done: " Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> a -> Builder
sp a
a
go a -> Builder
_ (BytesRead Int64
_ Int64 -> Decoder a
_) = Builder
"BytesRead"
{-# INLINE liftShowbPrec #-}