Safe conversions between Haskell textual types
Go to file
Alexis King 283d2f52a3 0.3.1.1
2022-05-02 17:31:23 -05:00
.github/workflows Convert to cabal project and use GitHub actions for CI 2022-05-02 17:08:54 -05:00
src/Data/Text Remove dependency on errors 2022-05-02 17:28:59 -05:00
test Add support for Base16 and Base64 encodings 2016-06-09 13:30:59 -07:00
.gitignore Convert to cabal project and use GitHub actions for CI 2022-05-02 17:08:54 -05:00
cabal.project Convert to cabal project and use GitHub actions for CI 2022-05-02 17:08:54 -05:00
cabal.project.ci Convert to cabal project and use GitHub actions for CI 2022-05-02 17:08:54 -05:00
CHANGELOG.md 0.3.1.1 2022-05-02 17:31:23 -05:00
LICENSE Initial commit 2016-05-24 16:37:34 -07:00
README.md 0.3.1.1 2022-05-02 17:31:23 -05:00
Setup.hs Initial commit 2016-05-24 16:37:34 -07:00
text-conversions.cabal 0.3.1.1 2022-05-02 17:31:23 -05:00

text-conversions Build Status Hackage

This is a small library to ease the pain when converting between the many different string types in Haskell. Unlike some other libraries that attempt to solve the same problem, text-conversions is:

  • Safe. This library treats binary data (aka ByteString) like binary data, and it does not assume a particular encoding, nor does it ever throw exceptions when failing to decode. It does, however, provide failable conversions between binary data and textual data.

  • Extensible. Its easy to add or derive your own instances of the typeclasses to use your own types through the same interface.

Heres an example of using text-conversions to convert between textual types:

> convertText ("hello" :: String) :: Text
"hello"

And heres an example of converting from UTF-8 encoded binary data to a textual format:

> decodeConvertText (UTF8 ("hello" :: ByteString)) :: Maybe Text
Just "hello"
> decodeConvertText (UTF8 ("\xc3\x28" :: ByteString)) :: Maybe Text
Nothing

For more details, see the documentation on Hackage.