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