Safe Haskell | None |
---|---|
Language | Haskell2010 |
Have you ever found yourself frustrated that you're spending 15-30% of your
time in Haskell converting between string types, remembering which module has
the toStrict
function, importing Data.Text.Encoding and
Data.Text.Lazy.Encoding qualified, spending time thinking about how to do
Base64 encoding, etc.? Or tried to use one of the (excellent) typeclass-based
string conversion libraries, only to find yourself adding awkward type
signatures to avoid type-inferencing ambiguities?
This module exports a collection of functions that follow a simple pattern:
stringTypeAToStringTypeB :: a -> b
This way, if you import this module unqualified, or as part of your Prelude, all you have to think about is which type you want to convert into which other type.
For convenience, this module also exposes conversions between Base16, Base32, and Base64-encoded strings.
Note:
- Not *every* possible permutation has a function, just each one we've ever needed. If you need one that's not included, please submit a pull request to add it.
- When converting a Text to and from ByteString, UTF-8 is used.
Synopsis
- base16ByteStringToByteString :: ByteString -> Either String ByteString
- base32ByteStringToByteString :: ByteString -> Either String ByteString
- base64ByteStringToByteString :: ByteString -> Either String ByteString
- base64UrlByteStringToByteString :: ByteString -> Either String ByteString
- base64ByteStringToText :: ByteString -> Either String Text
- byteStringToBase16ByteString :: ByteString -> ByteString
- byteStringToBase32ByteString :: ByteString -> ByteString
- byteStringToBase64ByteString :: ByteString -> ByteString
- byteStringToBase64UrlByteString :: ByteString -> ByteString
- byteStringToBase32Text :: ByteString -> Text
- byteStringToBase64Text :: ByteString -> Text
- byteStringToLazyByteString :: ByteString -> ByteString
- byteStringToString :: ByteString -> String
- byteStringToText :: ByteString -> Text
- lazyByteStringToByteString :: ByteString -> ByteString
- lazyByteStringToString :: ByteString -> String
- lazyByteStringToText :: ByteString -> Text
- base16TextToByteString :: Text -> Either String ByteString
- base32TextToByteString :: Text -> Either String ByteString
- base64TextToByteString :: Text -> Either String ByteString
- lazyTextToString :: Text -> String
- lazyTextToText :: Text -> Text
- textToBase16ByteString :: Text -> ByteString
- textToBase16String :: Text -> String
- textToBase16Text :: Text -> Text
- textToBase32ByteString :: Text -> ByteString
- textToBase32String :: Text -> String
- textToBase32Text :: Text -> Text
- textToBase64ByteString :: Text -> ByteString
- textToBase64String :: Text -> String
- textToBase64Text :: Text -> Text
- textToByteString :: Text -> ByteString
- textToLazyByteString :: Text -> ByteString
- textToLazyText :: Text -> Text
- textToString :: Text -> String
- stringToByteString :: String -> ByteString
- stringToLazyByteString :: String -> ByteString
- stringToLazyText :: String -> Text
- stringToText :: String -> Text
ByteString to...
byteStringToText :: ByteString -> Text Source #
Text to...
lazyTextToString :: Text -> String Source #
lazyTextToText :: Text -> Text Source #
textToBase16String :: Text -> String Source #
textToBase16Text :: Text -> Text Source #
textToBase32String :: Text -> String Source #
textToBase32Text :: Text -> Text Source #
textToBase64String :: Text -> String Source #
textToBase64Text :: Text -> Text Source #
textToByteString :: Text -> ByteString Source #
textToLazyText :: Text -> Text Source #
textToString :: Text -> String Source #
String to...
stringToLazyText :: String -> Text Source #
stringToText :: String -> Text Source #