module Unwitch.Convert.LazyByteString
( toByteString
, toWord8s
, fromWord8s
#ifdef __GLASGOW_HASKELL__
, toLazyTextLatin1
, toLazyTextUtf8
, toLazyTextUtf16LE
, toLazyTextUtf16BE
, toLazyTextUtf32LE
, toLazyTextUtf32BE
#endif
)
where
import Data.ByteString (ByteString)
import Data.ByteString.Lazy qualified as LBS
import Data.Word (Word8)
#ifdef __GLASGOW_HASKELL__
import Data.Text.Lazy qualified as LT
import Data.Text.Lazy.Encoding qualified as LTE
import Data.Text.Encoding.Error (UnicodeException)
import Unwitch.TryEvaluate (tryEvaluate)
#endif
toByteString :: LBS.ByteString -> ByteString
toByteString :: ByteString -> ByteString
toByteString = ByteString -> ByteString
LBS.toStrict
toWord8s :: LBS.ByteString -> [Word8]
toWord8s :: ByteString -> [Word8]
toWord8s = ByteString -> [Word8]
LBS.unpack
fromWord8s :: [Word8] -> LBS.ByteString
fromWord8s :: [Word8] -> ByteString
fromWord8s = [Word8] -> ByteString
LBS.pack
#ifdef __GLASGOW_HASKELL__
toLazyTextLatin1 :: LBS.ByteString -> LT.Text
toLazyTextLatin1 :: ByteString -> Text
toLazyTextLatin1 = ByteString -> Text
LTE.decodeLatin1
toLazyTextUtf8 :: LBS.ByteString -> Either UnicodeException LT.Text
toLazyTextUtf8 :: ByteString -> Either UnicodeException Text
toLazyTextUtf8 = ByteString -> Either UnicodeException Text
LTE.decodeUtf8'
toLazyTextUtf16LE :: LBS.ByteString -> Either UnicodeException LT.Text
toLazyTextUtf16LE :: ByteString -> Either UnicodeException Text
toLazyTextUtf16LE = Text -> Either UnicodeException Text
forall e a. Exception e => a -> Either e a
tryEvaluate (Text -> Either UnicodeException Text)
-> (ByteString -> Text)
-> ByteString
-> Either UnicodeException Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> Text
LTE.decodeUtf16LE
toLazyTextUtf16BE :: LBS.ByteString -> Either UnicodeException LT.Text
toLazyTextUtf16BE :: ByteString -> Either UnicodeException Text
toLazyTextUtf16BE = Text -> Either UnicodeException Text
forall e a. Exception e => a -> Either e a
tryEvaluate (Text -> Either UnicodeException Text)
-> (ByteString -> Text)
-> ByteString
-> Either UnicodeException Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> Text
LTE.decodeUtf16BE
toLazyTextUtf32LE :: LBS.ByteString -> Either UnicodeException LT.Text
toLazyTextUtf32LE :: ByteString -> Either UnicodeException Text
toLazyTextUtf32LE = Text -> Either UnicodeException Text
forall e a. Exception e => a -> Either e a
tryEvaluate (Text -> Either UnicodeException Text)
-> (ByteString -> Text)
-> ByteString
-> Either UnicodeException Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> Text
LTE.decodeUtf32LE
toLazyTextUtf32BE :: LBS.ByteString -> Either UnicodeException LT.Text
toLazyTextUtf32BE :: ByteString -> Either UnicodeException Text
toLazyTextUtf32BE = Text -> Either UnicodeException Text
forall e a. Exception e => a -> Either e a
tryEvaluate (Text -> Either UnicodeException Text)
-> (ByteString -> Text)
-> ByteString
-> Either UnicodeException Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> Text
LTE.decodeUtf32BE
#endif