typed-encoding: Type safe string transformations

[ bsd3, data, library, text ] [ Propose Tags ]

See README.md in the project github repository.


[Skip to Readme]
Versions [faq] 0.1.0.0, 0.2.0.0, 0.2.1.0, 0.2.2.0, 0.3.0.0, 0.3.0.1, 0.3.0.2, 0.4.0.0, 0.4.1.0, 0.4.2.0, 0.5.0.0
Change log ChangeLog.md
Dependencies base (>=4.7 && <5), base64-bytestring (==1.0.*), bytestring (==0.10.*), text (==1.2.*) [details]
License BSD-3-Clause
Copyright 2020 Robert Peszek
Author Robert Peszek
Maintainer robpeszek@gmail.com
Category Data, Text
Home page https://github.com/rpeszek/typed-encoding#readme
Bug tracker https://github.com/rpeszek/typed-encoding/issues
Source repo head: git clone https://github.com/rpeszek/typed-encoding
Uploaded by rpeszek at 2020-05-03T02:36:58Z
Distributions NixOS:0.4.2.0
Downloads 994 total (162 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs uploaded by user
Build status unknown [no reports yet]

Modules

[Index]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees


Readme for typed-encoding-0.2.0.0

[back to package description]

typed-encoding

Type level annotations, string transformations, and other goodies that make programming strings safer.

Motivation

I have recently spent a lot of time troubleshooting various Base64, quoted-printable, and UTF-8 encoding issues.
I decided to write a library that will help avoiding issues like these.

This library allows to specify and work with types like

-- some data encoded in base 64
mydata :: Enc '["enc-B64"] ByteString

-- some text (utf8) data encoded in base 64 
myData :: Enc '["enc-B64", "r-UTF8"] ByteString

It allows to define precise string content annotations like:

mydata :: Enc '["r-IpV4"] Text

and provides ways for

  • encoding
  • decoding
  • recreation (encoding validation)
  • type conversions
  • converting types to encoded strings
  • typesafe conversion of encoded strings to types

... but this approach seems to be a bit more...

-- upper cased text encoded as base64
example :: Enc '["enc-B64", "do-UPPER"] () T.Text
example = encodeAll . toEncoding () $ "some text goes here"

It becomes a type directed, declarative approach to string transformations.

Transformations can be

  • used with parameters.
  • applied or undone partially (if encoding is reversible)

Examples

Please see Examples.TypedEncoding it the module list.

Dependencies on other encoding libs

Currently it uses

  • base64-bytestring because it was my driving example
  • I will try to separate other deps like servant, specific encoding libraries, etc into separate libs if there is interest. I consider orphan instances to be OK in this context. (GHC will classify them as such despite use of unique symbols.)

Plans, some TODOs

  • lensifying conversions
  • better implementation type safety

Tested with

  • stack (1.9.3) lts-14.27 (ghc-8.6.5)

Known issues