Codec for values with a
Read and
Show instance.
Example:
We have the following type that represents the image format:
data Format
= Jpeg
| Png
| Gif
deriving (Show, Read, Enum)
And we want to be able to decode and encode this data type through the
Show and
Read instances.
To write the codec for
Format data type using the existing
instances we can use
read combinator. And now with the
Toml.read "foo" we can have the following line in our
TOML perfectly encoded:
foo = Gif
But the
foo = ".gif" will lead to the following error:
tomland decode error: Prelude.read: no parse