-- PrettyUtils.hs: prettyprinter helpers
-- Copyright © 2018-2022  Clint Adams
-- This software is released under the terms of the Expat license.
-- (See the LICENSE file).
module Codec.Encryption.OpenPGP.Types.Internal.PrettyUtils where

import qualified Data.ByteString.Lazy as BL
import Data.Text.Encoding (decodeUtf8With)
import Data.Text.Encoding.Error (lenientDecode)
import Prettyprinter (Doc, Pretty(..))

prettyBS :: ByteString -> Doc ann
prettyBS = Text -> Doc ann
forall ann. Text -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty (Text -> Doc ann) -> (ByteString -> Text) -> ByteString -> Doc ann
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OnDecodeError -> ByteString -> Text
decodeUtf8With OnDecodeError
lenientDecode

prettyLBS :: BL.ByteString -> Doc ann
prettyLBS :: forall ann. ByteString -> Doc ann
prettyLBS = Text -> Doc ann
forall ann. Text -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty (Text -> Doc ann) -> (ByteString -> Text) -> ByteString -> Doc ann
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OnDecodeError -> ByteString -> Text
decodeUtf8With OnDecodeError
lenientDecode (ByteString -> Text)
-> (ByteString -> ByteString) -> ByteString -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> ByteString
BL.toStrict