text-conversions

Safe conversions between textual types https://github.com/cjdev/text-conversions#readme

Version on this page:0.3.0
LTS Haskell 8.12:0.3.0
Stackage Nightly 2017-04-24:0.3.0
Latest on Hackage:0.3.0
ISC licensed by Alexis King
Maintained by lexi.lambda@gmail.com

Module documentation for 0.3.0

text-conversions

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
"hello"

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
Nothing

For more details, see the documentation on Hackage.

Changes

Changelog

0.2.0 (May 25, 2016)

Breaking Changes

  • The ConvertText typeclass has been split into two simpler functions, convertText and decodeConvertText. This means the vision of a unified function for converting between any two textual datatypes is no longer implemented, but the original attempt had too many problems to really be worth the cost. Specifically, instances like FromText (Maybe Foo) would cause problems due to the overlapping instances, which have now been removed.

0.1.0 (May 24, 2016)

  • Initial release
comments powered byDisqus