TTC, an initialism of Textual Type Classes, is a library that provides
Render and Parse type classes for conversion between data types and
textual data types (strings). Use the Show and Read type classes for
debugging/development, and use the Render and Parse type classes for your
own purposes. The library also provides various ways to validate constants at
compile-time.
This repository is used to maintain multiple, related Haskell packages.
- Package
ttcuses aTextualtype class for conversion between textual data types. This package uses simple types and compiles quickly, but the supported textual data types are fixed. It is not possible for users to add support for additional textual data types. - Package
ttc-examplescontainsttcusage examples.
The relude library has polymorphic versions of show and readEither in
Relude.String.Conversion, as well as various type classes for converting
between string types. This does not encourage using Show and Read
instances with syntactically valid Haskell syntax, and it encourages the using
of the String data type.
The rio library has a Display type class with a similar goal as
TTC.Render. Since the library encourages a uniform usage of textual data
types, Display only provides functions for rendering to Text and a builder
format. It does not have a type class similar to TTC.Parse.
The text-display library defines a Display type class intended to render
user-facing text. It uses a Builder type internally and renders to a Text
value.
Harry Garrood has an interesting series of blog posts about type classes and
Show:
- Down with Show! Part 1: Rules of thumb for when to use a type class
- Down with Show! Part 2: What's wrong with the Show type class
- Down with Show! Part 3: A replacement for Show
The qq-literals library creates a QuasiQuoter from a parse function of
type String -> Either String a. The functionality is similar to TTC's
mkUntypedValidQQ function. The mkUntypedValidQQ function allows the user
to choose the name of the QuasiQuoter because a name like valid is
preferred when used via a qualified import while a name like username may be
preferred when not using qualified imports. Note that mkUntypedValidQQ also
splices in an explicit type signature.
The validated-literals library has a Validate type class that is similar
to TTC.Parse but supports conversion between arbitrary types, not just from
textual data types. Template Haskell functions are provided to perform
validation at compile-time. Result types must either have Lift instances or
equivalent implementations.
Chris Done posted a gist about implementing statically checked overloaded strings.
There are a number of libraries that simplify conversion between string types.
The following libraries provide type classes with two type variables. The
primary benefit of this approach is that one can add support for any string
type. The drawback of this approach is that implementations of Render and
Parse using such a type class would have to be done via a fixed type,
resulting in unnecessary conversion when using other types.
The following library provide type classes with a single type variable, but conversion is done via a fixed type.
- hxt-regex-xmlschema has a
StringLiketype class and does conversion via theStringtype - ListLike has a
StringLiketype class and does conversion via theStringtype - monoid-subclasses provides a
TextualMonoidtype class that provides an abstract API over textual types, usingStringas the underlying type - stringlike converts via the
Texttype - tagsoup has a
StringLiketype class that provides an abstract API over textual types and acastStringfunction that converts via theStringtype - text-conversions converts via the
Texttype - textual (deprecated) converts via the
Stringtype
There are also a number of libraries that provide type classes for conversion between arbitrary types, including string types.
- basement provides type classes for conversion that may fail as well as conversion that cannot fail
- convertible
- witch provides type classes for conversion that may fail as well as conversion that cannot fail
- GitHub: https://github.com/ExtremaIS/ttc-haskell
- GitHub Actions CI: https://github.com/ExtremaIS/ttc-haskell/actions
The main branch is reserved for releases. It may be considered stable, and
HEAD is always the latest release.
The develop branch is the primary development branch. It contains changes
that have not yet been released, and it is not necessarily stable.
Hackage revisions are made for metadata changes, such as relaxation of
constraints when new versions of dependencies are released. The .cabal
metadata in the main branch may therefore not match that of Hackage. The
.cabal metadata in the develop branch may match, unless work is being
done on a new release that contains other changes.
All releases are tagged in the main branch. Release tags are signed using
the [email protected] GPG key.
Issues and feature requests are tracked on GitHub: https://github.com/ExtremaIS/ttc-haskell/issues
Issues may also be submitted via email to [email protected].
This project is released under the MIT License as specified in the
LICENSE file.