The text-conversions package

[ Tags: data, library ] [ Propose Tags ]

Safe conversions between textual types

[Skip to Readme]


Versions 0.1.0, 0.2.0, 0.3.0
Change log
Dependencies base (>=4.7 && <5), base16-bytestring, base64-bytestring, bytestring, errors, text [details]
License ISC
Author Alexis King
Category Data
Home page
Bug tracker
Source repository head: git clone
Uploaded Thu Jun 9 20:32:26 UTC 2016 by lexi_lambda
Distributions LTSHaskell:0.3.0, NixOS:0.3.0, Stackage:0.3.0, Tumbleweed:0.3.0
Downloads 239 total (14 in the last 30 days)
Rating 0.0 (0 ratings) [clear rating]
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2016-06-09 [all 1 reports]
Hackage Matrix CI




Maintainer's Corner

For package maintainers and hackage trustees

Readme for text-conversions-0.3.0

[back to package description]


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. It’s easy to add or derive your own instances of the typeclasses to use your own types through the same interface.

Here’s an example of using text-conversions to convert between textual types:

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

And here’s 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

For more details, see the documentation on Hackage.