# enum-utf8

An experimental toolkit for rendering enumerated types into `Utf8` from
the [`render-utf8`](http://hackage.haskell.org/package/render-utf8) package)
and parsing them back again with the provided `Utf8Parsable` type class.
It is based on the `render-utf8` and
[`enum-text`](http://hackage.haskell.org/package/enum-text) packages.

To get the `Buildable` and `TextParsable` instances for an enumerated data type
use the following pattern:

```
import Text.Enum.Utf8
import Text.Utf8

data Foo = FOO_bar | FOO_bar_baz
  deriving (Bounded,Enum,Eq,Ord,Show)

instance EnumUtf8     Foo
instance Renderable   Foo where render    = renderEnumUtf8
instance Utf8Parsable Foo where parseUtf8 = parseEnumUtf8

main :: IO ()
main = mapM_ (cvtLn . render) [minBound..maxBound::Foo]
```

This will use the default configuration for generating the text of each
enumeration from the derived `show` text, namely:

  * removing the prefix upto and including the first underscore (`_`);
  * converting each subsequent underscore (`_`) into a dash (`-`).

See the Haddocks for details on how to override this default configuration for
any given enumeration type.

Functions for generating and parsing UTF-8 encoded ByteStrings (suitable for
cassava), as are `Hashable` functions.