-- | -- Module : Test.Chuchu.Parsec -- Copyright : (c) Marco TĂșlio Pimenta Gontijo 2012 -- License : Apache 2.0 (see the file LICENSE) -- -- Maintainer : Marco TĂșlio Pimenta Gontijo -- Stability : unstable -- Portability : portable -- -- This is a very simplified parser for e-mail, which does not follow RFC5322. -- Basically, it parses @TEXT\@TEXT@, where TEXT is @alphaNum <|> oneOf -- "!#$%&'*+-/=?^_`{|}~."@. It's loosely based on -- . module Test.Chuchu.Email (addrSpecSimple) where import Control.Applicative ((<$>), (<|>)) import Text.Parsec (oneOf, many1, string, alphaNum) import Text.Parsec.Text (Parser) -- | Parses a simplified e-mail address and return everything that was parsed as -- a simple 'String'. addrSpecSimple :: Parser String addrSpecSimple = concat <$> sequence [atomWithDot, string "@", atomWithDot] atomWithDot :: Parser String atomWithDot = many1 atomTextWithDot atomTextWithDot :: Parser Char atomTextWithDot = alphaNum <|> oneOf "!#$%&'*+-/=?^_`{|}~."