module Verismith.Internal
(
safe
, showT
, showBS
, comma
, commaNL
)
where
import Data.ByteString (ByteString)
import Data.ByteString.Builder (byteStringHex, toLazyByteString)
import qualified Data.ByteString.Lazy as L
import Data.Text (Text)
import qualified Data.Text as T
import Data.Text.Encoding (decodeUtf8)
showBS :: ByteString -> Text
showBS = decodeUtf8 . L.toStrict . toLazyByteString . byteStringHex
safe :: ([a] -> b) -> [a] -> Maybe b
safe _ [] = Nothing
safe f l = Just $ f l
showT :: (Show a) => a -> Text
showT = T.pack . show
comma :: [Text] -> Text
comma = T.intercalate ", "
commaNL :: [Text] -> Text
commaNL = T.intercalate ",\n"