module TextShow.Data.Binary (showbDecoderWith) where
import Data.Binary.Get.Internal (Decoder(..))
import Data.Monoid.Compat
import TextShow (TextShow(..), TextShow1(..), Builder, fromString, showbPrec1)
#include "inline.h"
showbDecoderWith :: (a -> Builder) -> Decoder a -> Builder
showbDecoderWith _ (Fail _ msg) = "Fail: " <> fromString msg
showbDecoderWith _ (Partial _) = "Partial _"
showbDecoderWith sp (Done _ a) = "Done: " <> sp a
showbDecoderWith _ (BytesRead _ _) = "BytesRead"
instance TextShow a => TextShow (Decoder a) where
showbPrec = showbPrec1
INLINE_INST_FUN(showbPrec)
instance TextShow1 Decoder where
showbPrecWith sp _ = showbDecoderWith $ sp 0
INLINE_INST_FUN(showbPrecWith)