Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
- isValidEmail :: Text -> Bool
- data EmailAddress = EmailAddress {
- localPart :: Text
- domainPart :: Text
- emailToText :: EmailAddress -> Text
- parseEmail :: Text -> Either String EmailAddress
- emailParser :: Parser EmailAddress
Validating
isValidEmail :: Text -> Bool Source
Validates given email. Email shouldn't have trailing or preceding spaces
>>>
:set -XOverloadedStrings
>>>
isValidEmail "name@example.com"
True>>>
isValidEmail "name@example..com"
False
Parsing
data EmailAddress Source
Represents an email address
EmailAddress | |
|
emailToText :: EmailAddress -> Text Source
Convert to text.
>>>
emailToText $ EmailAddress "name" "example.com"
"name@example.com
parseEmail :: Text -> Either String EmailAddress Source
Parce an email. Error messages aren't very helpful.
emailParser :: Parser EmailAddress Source
Attoparsec parser.