-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
5 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,9 +17,8 @@ import Text.Email.Validate (validate, localPart, domainPart, unsafeEmailAddress) | |
|
||
-- | A QuasiQuoter for email addresses. | ||
-- | ||
-- Use it like this: | ||
-- Use it like this (requires `QuasiQuotes` to be enabled): | ||
-- | ||
-- >>> :set -XQuasiQuotes | ||
-- >>> [email|[email protected]|] | ||
-- "[email protected]" | ||
email :: QuasiQuoter | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,19 +24,14 @@ import Text.Email.Parser | |
, toByteString | ||
, unsafeEmailAddress) | ||
|
||
-- $setup | ||
-- This is required for all examples: | ||
-- | ||
-- >>> :set -XOverloadedStrings | ||
|
||
-- | Smart constructor for an email address | ||
emailAddress :: ByteString -> Maybe EmailAddress | ||
emailAddress = either (const Nothing) Just . validate | ||
|
||
-- | Checks that an email is valid and returns a version of it | ||
-- where comments and whitespace have been removed. | ||
-- | ||
-- Example: | ||
-- Example (requires `OverloadedStrings` to be enabled): | ||
-- | ||
-- >>> canonicalizeEmail "spaces. are. [email protected]" | ||
-- Just "[email protected]" | ||
|
@@ -51,7 +46,7 @@ isValid = either (const False) (const True) . validate | |
-- | If you want to find out *why* a particular string is not | ||
-- an email address, use this. | ||
-- | ||
-- Examples: | ||
-- Examples (both require `OverloadedStrings` to be enabled): | ||
-- | ||
-- >>> validate "[email protected]" | ||
-- Right "[email protected]" | ||
|
@@ -60,4 +55,3 @@ isValid = either (const False) (const True) . validate | |
-- Left "at sign > @: not enough input" | ||
validate :: ByteString -> Either String EmailAddress | ||
validate = parseOnly (addrSpec >>= \r -> endOfInput >> return r) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters