module Data.ByteString.Base16
( encodeBase16
, encodeBase16'
, decodeBase16
, decodeBase16'
, decodeBase16Untyped
, decodeBase16Lenient
, parseBase16
) where
import Data.Base16.Types
import Data.ByteString (ByteString)
import Data.ByteString.Base16.Internal.Head
import Data.Text (Text)
import qualified Data.Text.Encoding as T
encodeBase16 :: ByteString -> Base16 Text
encodeBase16 :: ByteString -> Base16 Text
encodeBase16 = (ByteString -> Text) -> Base16 ByteString -> Base16 Text
forall a b. (a -> b) -> Base16 a -> Base16 b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ByteString -> Text
T.decodeUtf8 (Base16 ByteString -> Base16 Text)
-> (ByteString -> Base16 ByteString) -> ByteString -> Base16 Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> Base16 ByteString
encodeBase16'
{-# INLINE encodeBase16 #-}
encodeBase16' :: ByteString -> Base16 ByteString
encodeBase16' :: ByteString -> Base16 ByteString
encodeBase16' = ByteString -> Base16 ByteString
forall a. a -> Base16 a
assertBase16 (ByteString -> Base16 ByteString)
-> (ByteString -> ByteString) -> ByteString -> Base16 ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> ByteString
encodeBase16_
{-# INLINE encodeBase16' #-}
decodeBase16 :: Base16 ByteString -> ByteString
decodeBase16 :: Base16 ByteString -> ByteString
decodeBase16 = Base16 ByteString -> ByteString
decodeBase16Typed_
{-# INLINE decodeBase16 #-}
decodeBase16' :: Base16 Text -> ByteString
decodeBase16' :: Base16 Text -> ByteString
decodeBase16' = Base16 ByteString -> ByteString
decodeBase16Typed_ (Base16 ByteString -> ByteString)
-> (Base16 Text -> Base16 ByteString) -> Base16 Text -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Text -> ByteString) -> Base16 Text -> Base16 ByteString
forall a b. (a -> b) -> Base16 a -> Base16 b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Text -> ByteString
T.encodeUtf8
{-# INLINE decodeBase16' #-}
decodeBase16Untyped :: ByteString -> Either Text ByteString
decodeBase16Untyped :: ByteString -> Either Text ByteString
decodeBase16Untyped = ByteString -> Either Text ByteString
decodeBase16_
{-# INLINE decodeBase16Untyped #-}
decodeBase16Lenient :: ByteString -> ByteString
decodeBase16Lenient :: ByteString -> ByteString
decodeBase16Lenient = ByteString -> ByteString
decodeBase16Lenient_
{-# INLINE decodeBase16Lenient #-}
parseBase16 :: ByteString -> Either Text (Base16 ByteString)
parseBase16 :: ByteString -> Either Text (Base16 ByteString)
parseBase16 ByteString
bs = ByteString -> Base16 ByteString
forall a. a -> Base16 a
assertBase16 ByteString
bs Base16 ByteString
-> Either Text ByteString -> Either Text (Base16 ByteString)
forall a b. a -> Either Text b -> Either Text a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ByteString -> Either Text ByteString
decodeBase16Untyped ByteString
bs
{-# INLINE parseBase16 #-}