Porges/email-validate-hs — pull request #6 by k0001 (2014-01-17 23:31:37+00:00)
Title: Change EmailAddress' Show instance to be compatible with ByteString's and its own new Read instance.

Currently, the `Show` instance for `EmailAddress` works as follows:

```haskell
>>> show (fromJust $ Text.Email.Validate.emailAddress "foo@bar.com")
"foo@bar.com"
```

Whereas trying to `show` the underlying `ByteString` yields a different result:

```haskell
>>> show ("foo@bar.com" :: ByteString)
"\"foo@bar.com\""
```

In this pull-request I propose a **backwards incompatible** change: that the `EmailAddress`'s `Show` instance behaves like that of `ByteString` (and `String` and `Text`), which renders as a valid Haskell expression.

The main reason why I'm interested in this change is not the behavior of `Show` itself, but instead, I'm interested in adding a `Read` instance for `EmailAddress` compatible with `Show` (that is, `read . show = id`). Automatically derived `Show` and `Read` instances have this behavior. However, given that email addresses can contain whitespace and other _funny_ characters like `(` a `)`, I doubt it is possible to do so unless the email address is well-delimited (as it is in the case of `ByteString`'s `Read` instance for example, where `"` is used as a delimiter).

So, given that `Read` and `Show` are quite handy when doing basic serialization and deserialization routines, and that `EmailAddress` is frequently used as part of a larger structure (say, the contact details for a client) that could otherwise be `show`n and `read` back: Could we ease this serialization and deserialization routines by providing these two new instances by default?

In this pull-request I provide an implementation and some tests.