-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Parsec parsers for the RFC2822 Internet Message format -- -- Parsec parsers for the Internet Message format defined in RFC 2821 and -- 2822. @package hsemail @version 2 -- | This module provides parsers for the grammar defined in RFC2234, -- "Augmented BNF for Syntax Specifications: ABNF", -- http://www.faqs.org/rfcs/rfc2234.html. The terminal called -- char in the RFC is called character here to avoid -- conflicts with Parsec's char function. module Text.Parsec.Rfc2234 -- | Case-insensitive variant of Parsec's char function. caseChar :: Stream s m Char => Char -> ParsecT s u m Char -- | Case-insensitive variant of Parsec's string function. caseString :: Stream s m Char => String -> ParsecT s u m () -- | Match a parser at least n times. manyN :: Int -> ParsecT s u m a -> ParsecT s u m [a] -- | Match a parser at least n times, but no more than m -- times. manyNtoM :: Int -> Int -> ParsecT s u m a -> ParsecT s u m [a] -- | Helper function to generate Parser-based instances for the -- Read class. parsec2read :: Parser a -> String -> [(a, String)] -- | Match any character of the alphabet. alpha :: Stream s m Char => ParsecT s u m Char -- | Match either "1" or "0". bit :: Stream s m Char => ParsecT s u m Char -- | Match any 7-bit US-ASCII character except for NUL (ASCII value 0, that -- is). character :: Stream s m Char => ParsecT s u m Char -- | Match the carriage return character \r. cr :: Stream s m Char => ParsecT s u m Char -- | Match returns the linefeed character \n. lf :: Stream s m Char => ParsecT s u m Char -- | Match the Internet newline \r\n. crlf :: Stream s m Char => ParsecT s u m String -- | Match any US-ASCII control character. That is any character with a -- decimal value in the range of [0..31,127]. ctl :: Stream s m Char => ParsecT s u m Char -- | Match the double quote character """. dquote :: Stream s m Char => ParsecT s u m Char -- | Match any character that is valid in a hexadecimal number; ['0'..'9'] -- and ['A'..'F','a'..'f'] that is. hexdig :: Stream s m Char => ParsecT s u m Char -- | Match the tab ("\t") character. htab :: Stream s m Char => ParsecT s u m Char -- | Match "linear white-space". That is any number of consecutive -- wsp, optionally followed by a crlf and (at least) one -- more wsp. lwsp :: Stream s m Char => ParsecT s u m String -- | Match any character. octet :: Stream s m Char => ParsecT s u m Char -- | Match the space. sp :: Stream s m Char => ParsecT s u m Char -- | Match any printable ASCII character. (The "v" stands for "visible".) -- That is any character in the decimal range of [33..126]. vchar :: Stream s m Char => ParsecT s u m Char -- | Match either sp or htab. wsp :: Stream s m Char => ParsecT s u m Char -- | Match a "quoted pair". Any characters (excluding CR and LF) may be -- quoted. quoted_pair :: Stream s m Char => ParsecT s u m String -- | Match a quoted string. The specials "\" and """ must -- be escaped inside a quoted string; CR and LF are not allowed at all. quoted_string :: Stream s m Char => ParsecT s u m String -- | This module exports parser combinators for the grammar described in -- RFC2821, "Simple Mail Transfer Protocol", -- http://www.faqs.org/rfcs/rfc2821.html. module Text.Parsec.Rfc2821 data SessionState Unknown :: SessionState HaveHelo :: SessionState HaveMailFrom :: SessionState HaveRcptTo :: SessionState HaveData :: SessionState HaveQuit :: SessionState data Event -- | reserved for the user Greeting :: Event SayHelo :: String -> Event SayHeloAgain :: String -> Event SayEhlo :: String -> Event SayEhloAgain :: String -> Event SetMailFrom :: Mailbox -> Event AddRcptTo :: Mailbox -> Event StartData :: Event -- | reserved for the user Deliver :: Event NeedHeloFirst :: Event NeedMailFromFirst :: Event NeedRcptToFirst :: Event -- | Turn, Send, Soml, Saml, Vrfy, and -- Expn. NotImplemened :: Event ResetState :: Event -- | Triggered in case of Noop or when Rset is used before we -- even have a state. SayOK :: Event -- | The parameter may be []. SeeksHelp :: String -> Event Shutdown :: Event SyntaxErrorIn :: String -> Event Unrecognized :: String -> Event type SmtpdFSM = State SessionState Event -- | Parse a line of SMTP dialogue and run handleSmtpCmd to -- determine the Event. In case of syntax errors, -- SyntaxErrorIn or Unrecognized will be returned. Inputs -- must be terminated with crlf. See fixCRLF. smtpdFSM :: String -> SmtpdFSM -- | For those who want to parse the SmtpCmd themselves. Calling -- this function in HaveQuit or HaveData will fail an -- assertion. If assert is disabled, it will return respectively -- Shutdown and StartData again. handleSmtpCmd :: SmtpCmd -> SmtpdFSM -- | The smtpCmd parser will create this data type from a string. -- Note that all command parsers expect their input to be -- terminated with crlf. data SmtpCmd Helo :: String -> SmtpCmd Ehlo :: String -> SmtpCmd -- | Might be nullPath. MailFrom :: Mailbox -> SmtpCmd -- | Might be postmaster. RcptTo :: Mailbox -> SmtpCmd Data :: SmtpCmd Rset :: SmtpCmd Send :: Mailbox -> SmtpCmd Soml :: Mailbox -> SmtpCmd Saml :: Mailbox -> SmtpCmd Vrfy :: String -> SmtpCmd Expn :: String -> SmtpCmd -- | Might be []. Help :: String -> SmtpCmd -- | Optional argument ignored. Noop :: SmtpCmd Quit :: SmtpCmd Turn :: SmtpCmd -- | When a valid command has been recognized, but the argument parser -- fails, then this type will be returned. The String contains the -- name of the command (in all upper-case) and the ParseError is, -- obviously, the error description. WrongArg :: String -> ParseError -> SmtpCmd -- | The most general e-mail address has the form: -- <[@route,...:]user@domain>. This type, too, supports -- show and read. Note that a "shown" address is -- always enclosed in angular brackets. When comparing two -- mailboxes for equality, the hostname is case-insensitive. data Mailbox Mailbox :: [String] -> String -> String -> Mailbox -- | nullPath = Mailbox [] "" "" = -- "<>" nullPath :: Mailbox -- | postmaster = Mailbox [] "postmaster" "" = -- "<postmaster>" postmaster :: Mailbox -- | An SMTP reply is a three-digit return code plus some waste of -- bandwidth called "comments". This is what the list of strings is for; -- one string per line in the reply. show will append an -- "\r\n" end-of-line marker to each entry in that list, so that -- the resulting string is ready to be sent back to the peer. For -- example: -- --
--   >>> show $ Reply (Code Success MailSystem 0) ["worked", "like", "a charm" ]
--   "250-worked\r\n250-like\r\n250 a charm\r\n"
--   
-- -- If the message is an empty list [], a default text will be -- constructed: -- --
--   >>> show $ Reply (Code Success MailSystem 0) []
--   "250 Success in category MailSystem\r\n"
--   
data SmtpReply Reply :: SmtpCode -> [String] -> SmtpReply data SmtpCode Code :: SuccessCode -> Category -> Int -> SmtpCode data SuccessCode Unused0 :: SuccessCode PreliminarySuccess :: SuccessCode Success :: SuccessCode IntermediateSuccess :: SuccessCode TransientFailure :: SuccessCode PermanentFailure :: SuccessCode data Category Syntax :: Category Information :: Category Connection :: Category Unspecified3 :: Category Unspecified4 :: Category MailSystem :: Category -- | Construct a Reply. Fails assert if invalid numbers are -- given. reply :: Int -> Int -> Int -> [String] -> SmtpReply -- | A reply constitutes "success" if the status code is any of -- PreliminarySuccess, Success, or -- IntermediateSuccess. isSuccess :: SmtpReply -> Bool -- | A reply constitutes "failure" if the status code is either -- PermanentFailure or TransientFailure. isFailure :: SmtpReply -> Bool -- | The replies 221 and 421 signify Shutdown. isShutdown :: SmtpReply -> Bool -- | The SMTP parsers defined here correspond to the commands specified in -- RFC2821, so I won't document them individually. -- -- This parser recognizes any of the SMTP commands defined below. Note -- that all command parsers expect their input to be terminated -- with crlf. smtpCmd :: Stream s m Char => ParsecT s u m SmtpCmd -- | The parser name "data" was taken. smtpData :: Stream s m Char => ParsecT s u m SmtpCmd rset :: Stream s m Char => ParsecT s u m SmtpCmd quit :: Stream s m Char => ParsecT s u m SmtpCmd turn :: Stream s m Char => ParsecT s u m SmtpCmd helo :: Stream s m Char => ParsecT s u m SmtpCmd ehlo :: Stream s m Char => ParsecT s u m SmtpCmd mail :: Stream s m Char => ParsecT s u m SmtpCmd rcpt :: Stream s m Char => ParsecT s u m SmtpCmd send :: Stream s m Char => ParsecT s u m SmtpCmd soml :: Stream s m Char => ParsecT s u m SmtpCmd saml :: Stream s m Char => ParsecT s u m SmtpCmd vrfy :: Stream s m Char => ParsecT s u m SmtpCmd expn :: Stream s m Char => ParsecT s u m SmtpCmd help :: Stream s m Char => ParsecT s u m SmtpCmd -- | May have an optional word argument, but it is ignored. noop :: Stream s m Char => ParsecT s u m SmtpCmd from_path :: Stream s m Char => ParsecT s u m Mailbox to_path :: Stream s m Char => ParsecT s u m Mailbox path :: Stream s m Char => ParsecT s u m Mailbox mailbox :: Stream s m Char => ParsecT s u m Mailbox local_part :: Stream s m Char => ParsecT s u m String domain :: Stream s m Char => ParsecT s u m String a_d_l :: Stream s m Char => ParsecT s u m [String] at_domain :: Stream s m Char => ParsecT s u m String -- | TODO: Add IPv6 address and general literals address_literal :: Stream s m Char => ParsecT s u m String ipv4_literal :: Stream s m Char => ParsecT s u m String ipv4addr :: Stream s m Char => ParsecT s u m String subdomain :: Stream s m Char => ParsecT s u m String dot_string :: Stream s m Char => ParsecT s u m String atom :: Stream s m Char => ParsecT s u m String snum :: Stream s m Char => ParsecT s u m String number :: Stream s m Char => ParsecT s u m String -- | This is a useful addition: The parser accepts an atom or a -- quoted_string. word :: Stream s m Char => ParsecT s u m String -- | Make the string crlf terminated no matter what. '\n' -- is expanded, otherwise crlf is appended. Note that if the -- string was terminated incorrectly before, it still is. This function -- is useful when reading input with hGetLine which removes the -- end-of-line delimiter. fixCRLF :: String -> String -- | Construct a parser for a command without arguments. Expects -- crlf! mkCmd0 :: Stream s m Char => String -> a -> ParsecT s u m a -- | Construct a parser for a command with an argument, which the given -- parser will handle. The result of the argument parser will be applied -- to the type constructor before it is returned. Expects crlf! mkCmd1 :: Stream s m Char => String -> (a -> SmtpCmd) -> ParsecT s u m a -> ParsecT s u m SmtpCmd tokenList :: Stream s m Char => ParsecT s u m String -> Char -> ParsecT s u m String instance GHC.Show.Show Text.Parsec.Rfc2821.Category instance GHC.Classes.Ord Text.Parsec.Rfc2821.Category instance GHC.Classes.Eq Text.Parsec.Rfc2821.Category instance GHC.Enum.Bounded Text.Parsec.Rfc2821.Category instance GHC.Enum.Enum Text.Parsec.Rfc2821.Category instance GHC.Show.Show Text.Parsec.Rfc2821.SuccessCode instance GHC.Classes.Ord Text.Parsec.Rfc2821.SuccessCode instance GHC.Classes.Eq Text.Parsec.Rfc2821.SuccessCode instance GHC.Enum.Bounded Text.Parsec.Rfc2821.SuccessCode instance GHC.Enum.Enum Text.Parsec.Rfc2821.SuccessCode instance GHC.Show.Show Text.Parsec.Rfc2821.Event instance GHC.Classes.Eq Text.Parsec.Rfc2821.Event instance GHC.Show.Show Text.Parsec.Rfc2821.SessionState instance GHC.Classes.Ord Text.Parsec.Rfc2821.SessionState instance GHC.Classes.Eq Text.Parsec.Rfc2821.SessionState instance GHC.Enum.Bounded Text.Parsec.Rfc2821.SessionState instance GHC.Enum.Enum Text.Parsec.Rfc2821.SessionState instance GHC.Show.Show Text.Parsec.Rfc2821.SmtpCmd instance GHC.Classes.Eq Text.Parsec.Rfc2821.Mailbox instance GHC.Show.Show Text.Parsec.Rfc2821.Mailbox instance GHC.Read.Read Text.Parsec.Rfc2821.Mailbox instance GHC.Show.Show Text.Parsec.Rfc2821.SmtpReply instance GHC.Show.Show Text.Parsec.Rfc2821.SmtpCode -- | This module provides parsers for the grammar defined in RFC2822, -- "Internet Message Format", -- http://www.faqs.org/rfcs/rfc2822.html. module Text.Parsec.Rfc2822 -- | Return Nothing if the given parser doesn't match. This -- combinator is included in the latest parsec distribution as -- optionMaybe, but ghc-6.6.1 apparently doesn't have it. maybeOption :: Stream s m Char => ParsecT s u m a -> ParsecT s u m (Maybe a) -- | unfold = between (optional cfws) (optional -- cfws) unfold :: Stream s m Char => ParsecT s u m a -> ParsecT s u m a -- | Construct a parser for a message header line from the header's name -- and a parser for the body. header :: Stream s m Char => String -> ParsecT s u m a -> ParsecT s u m a -- | Like header, but allows the obsolete white-space rules. obs_header :: Stream s m Char => String -> ParsecT s u m a -> ParsecT s u m a -- | Match any US-ASCII non-whitespace control character. no_ws_ctl :: Stream s m Char => ParsecT s u m Char -- | Match any US-ASCII character except for r, n. text :: Stream s m Char => ParsecT s u m Char -- | Match any of the RFC's "special" characters: -- ()<>[]:;@,.\". specials :: Stream s m Char => ParsecT s u m Char -- | Match a "quoted pair". All characters matched by text may be -- quoted. Note that the parsers returns both characters, the -- backslash and the actual content. quoted_pair :: Stream s m Char => ParsecT s u m String -- | Match "folding whitespace". That is any combination of wsp and -- crlf followed by wsp. fws :: Stream s m Char => ParsecT s u m String -- | Match any non-whitespace, non-control character except for -- "(", ")", and "\". This is used to describe -- the legal content of comments. -- -- Note: This parser accepts 8-bit characters, even though this is -- not legal according to the RFC. Unfortunately, 8-bit content in -- comments has become fairly common in the real world, so we'll just -- accept the fact. ctext :: Stream s m Char => ParsecT s u m Char -- | Match a "comments". That is any combination of ctext, -- quoted_pairs, and fws between brackets. Comments may -- nest. comment :: Stream s m Char => ParsecT s u m String -- | Match any combination of fws and comments. cfws :: Stream s m Char => ParsecT s u m String -- | Match any US-ASCII character except for control characters, -- specials, or space. atom and dot_atom are made up -- of this. atext :: Stream s m Char => ParsecT s u m Char -- | Match one or more atext characters and skip any preceeding or -- trailing cfws. atom :: Stream s m Char => ParsecT s u m String -- | Match dot_atom_text and skip any preceeding or trailing -- cfws. dot_atom :: Stream s m Char => ParsecT s u m String -- | Match two or more atexts interspersed by dots. dot_atom_text :: Stream s m Char => ParsecT s u m String -- | Match any non-whitespace, non-control US-ASCII character except for -- "\" and """. qtext :: Stream s m Char => ParsecT s u m Char -- | Match either qtext or quoted_pair. qcontent :: Stream s m Char => ParsecT s u m String -- | Match any number of qcontent between double quotes. Any -- cfws preceeding or following the "atom" is skipped -- automatically. quoted_string :: Stream s m Char => ParsecT s u m String -- | Match either atom or quoted_string. word :: Stream s m Char => ParsecT s u m String -- | Match either one or more words or an obs_phrase. phrase :: Stream s m Char => ParsecT s u m [String] -- | Match any non-whitespace, non-control US-ASCII character except for -- "\" and """. utext :: Stream s m Char => ParsecT s u m Char -- | Match any number of utext tokens. -- -- "Unstructured text" is used in free text fields such as -- subject. Please note that any comments or whitespace that -- prefaces or follows the actual utext is included in the -- returned string. unstructured :: Stream s m Char => ParsecT s u m String -- | Parse a date and time specification of the form -- --
--   Thu, 19 Dec 2002 20:35:46 +0200
--   
-- -- where the weekday specification "Thu," is optional. The -- parser returns a CalendarTime, which is set to the appropriate -- values. Note, though, that not all fields of CalendarTime will -- necessarily be set correctly! Obviously, when no weekday has been -- provided, the parser will set this field to Monday - regardless -- of whether the day actually is a monday or not. Similarly, the day of -- the year will always be returned as 0. The timezone name will -- always be empty: "". -- -- Nor will the date_time parser perform any consistency -- checking. It will accept -- --
--   40 Apr 2002 13:12 +0100
--   
-- -- as a perfectly valid date. -- -- In order to get all fields set to meaningful values, and in order to -- verify the date's consistency, you will have to feed it into any of -- the conversion routines provided in System.Time, such as -- toClockTime. (When doing this, keep in mind that most functions -- return local time. This will not necessarily be the time you're -- expecting.) date_time :: Stream s m Char => ParsecT s u m CalendarTime -- | This parser matches a day_name or an obs_day_of_week -- (optionally wrapped in folding whitespace) and return its Day -- value. day_of_week :: Stream s m Char => ParsecT s u m Day -- | This parser will the abbreviated weekday names ("Mon", -- "Tue", ...) and return the appropriate Day value. day_name :: Stream s m Char => ParsecT s u m Day -- | This parser will match a date of the form "dd:mm:yyyy" and -- return a tripple of the form (Int,Month,Int) - corresponding to -- (year,month,day). date :: Stream s m Char => ParsecT s u m (Int, Month, Int) -- | This parser will match a four digit number and return its integer -- value. No range checking is performed. year :: Stream s m Char => ParsecT s u m Int -- | This parser will match a month_name, optionally wrapped in -- folding whitespace, or an obs_month and return its Month -- value. month :: Stream s m Char => ParsecT s u m Month -- | This parser will the abbreviated month names ("Jan", -- "Feb", ...) and return the appropriate Month value. month_name :: Stream s m Char => ParsecT s u m Month day_of_month :: Stream s m Char => ParsecT s u m Int -- | Match a 1 or 2-digit number (day of month), recognizing both standard -- and obsolete folding syntax. day :: Stream s m Char => ParsecT s u m Int -- | This parser will match a time_of_day specification followed by -- a zone. It returns the tuple (TimeDiff,Int) corresponding to -- the return values of either parser. time :: Stream s m Char => ParsecT s u m (TimeDiff, Int) -- | This parser will match a time-of-day specification of "hh:mm" -- or "hh:mm:ss" and return the corrsponding time as a -- TimeDiff. time_of_day :: Stream s m Char => ParsecT s u m TimeDiff -- | This parser will match a two-digit number and return its integer -- value. No range checking is performed. hour :: Stream s m Char => ParsecT s u m Int -- | This parser will match a two-digit number and return its integer -- value. No range checking is performed. minute :: Stream s m Char => ParsecT s u m Int -- | This parser will match a two-digit number and return its integer -- value. No range checking takes place. second :: Stream s m Char => ParsecT s u m Int -- | This parser will match a timezone specification of the form -- "+hhmm" or "-hhmm" and return the zone's offset to -- UTC in seconds as an integer. obs_zone is matched as well. zone :: Stream s m Char => ParsecT s u m Int -- | A NameAddr is composed of an optional realname a mandatory e-mail -- address. data NameAddr NameAddr :: Maybe String -> String -> NameAddr [nameAddr_name] :: NameAddr -> Maybe String [nameAddr_addr] :: NameAddr -> String -- | Parse a single mailbox or an address group and return -- the address(es). address :: Stream s m Char => ParsecT s u m [NameAddr] -- | Parse a name_addr or an addr_spec and return the -- address. mailbox :: Stream s m Char => ParsecT s u m NameAddr -- | Parse an angle_addr, optionally prefaced with a -- display_name, and return the address. name_addr :: Stream s m Char => ParsecT s u m NameAddr -- | Parse an angle_addr or an obs_angle_addr and return the -- address. angle_addr :: Stream s m Char => ParsecT s u m String -- | Parse a "group" of addresses. That is a display_name, followed -- by a colon, optionally followed by a mailbox_list, followed by -- a semicolon. The found address(es) are returned - what may be none. -- Here is an example: -- --
--   >>> parse group "" "my group: user1@example.org, user2@example.org;"
--   Right [NameAddr {nameAddr_name = Nothing, nameAddr_addr = "user1@example.org"},NameAddr {nameAddr_name = Nothing, nameAddr_addr = "user2@example.org"}]
--   
group :: Stream s m Char => ParsecT s u m [NameAddr] -- | Parse and return a phrase. display_name :: Stream s m Char => ParsecT s u m String -- | Parse a list of mailbox addresses, every two addresses being -- separated by a comma, and return the list of found address(es). mailbox_list :: Stream s m Char => ParsecT s u m [NameAddr] -- | Parse a list of address addresses, every two addresses being -- separated by a comma, and return the list of found address(es). address_list :: Stream s m Char => ParsecT s u m [NameAddr] -- | Parse an "address specification". That is a local_part, -- followed by an "@" character, followed by a domain. -- Return the complete address as String, ignoring any whitespace -- or any comments. addr_spec :: Stream s m Char => ParsecT s u m String -- | Parse and return a "local part" of an addr_spec. That is either -- a dot_atom or a quoted_string. local_part :: Stream s m Char => ParsecT s u m String -- | Parse and return a "domain part" of an addr_spec. That is -- either a dot_atom or a domain_literal. domain :: Stream s m Char => ParsecT s u m String -- | Parse a "domain literal". That is a "[" character, followed -- by any amount of dcontent, followed by a terminating -- "]" character. The complete string is returned verbatim. domain_literal :: Stream s m Char => ParsecT s u m String -- | Parse and return any characters that are legal in a -- domain_literal. That is dtext or a quoted_pair. dcontent :: Stream s m Char => ParsecT s u m String -- | Parse and return any ASCII characters except "[", -- "]", and "\". dtext :: Stream s m Char => ParsecT s u m Char -- | This data type repesents a parsed Internet Message as defined in this -- RFC. It consists of an arbitrary number of header lines, represented -- in the Field data type, and a message body, which may be empty. data GenericMessage a Message :: [Field] -> a -> GenericMessage a -- | Parse a complete message as defined by this RFC and it broken down -- into the separate header fields and the message body. Header lines, -- which contain syntax errors, will not cause the parser to abort. -- Rather, these headers will appear as OptionalFields (which are -- unparsed) in the resulting Message. A message must be really, -- really badly broken for this parser to fail. -- -- This behaviour was chosen because it is impossible to predict what the -- user of this module considers to be a fatal error; traditionally, -- parsers are very forgiving when it comes to Internet messages. -- -- If you want to implement a really strict parser, you'll have to put -- the appropriate parser together yourself. You'll find that this is -- rather easy to do. Refer to the fields parser for further -- details. message :: (Monoid s, Stream s m Char) => ParsecT s u m (GenericMessage s) -- | A message body is just an unstructured sequence of characters. body :: (Monoid s, Monad m) => ParsecT s u m s -- | This data type represents any of the header fields defined in this -- RFC. Each of the various instances contains with the return value of -- the corresponding parser. data Field OptionalField :: String -> String -> Field From :: [NameAddr] -> Field Sender :: NameAddr -> Field ReturnPath :: String -> Field ReplyTo :: [NameAddr] -> Field To :: [NameAddr] -> Field Cc :: [NameAddr] -> Field Bcc :: [NameAddr] -> Field MessageID :: String -> Field InReplyTo :: [String] -> Field References :: [String] -> Field Subject :: String -> Field Comments :: String -> Field Keywords :: [[String]] -> Field Date :: CalendarTime -> Field ResentDate :: CalendarTime -> Field ResentFrom :: [NameAddr] -> Field ResentSender :: NameAddr -> Field ResentTo :: [NameAddr] -> Field ResentCc :: [NameAddr] -> Field ResentBcc :: [NameAddr] -> Field ResentMessageID :: String -> Field ResentReplyTo :: [NameAddr] -> Field Received :: ([(String, String)], CalendarTime) -> Field ObsReceived :: [(String, String)] -> Field -- | This parser will parse an arbitrary number of header fields as defined -- in this RFC. For each field, an appropriate Field value is -- created, all of them making up the Field list that this parser -- returns. -- -- If you look at the implementation of this parser, you will find that -- it uses Parsec's try modifier around all of the fields. -- The idea behind this is that fields, which contain syntax errors, fall -- back to the catch-all optional_field. Thus, this parser will -- hardly ever return a syntax error -- what conforms with the idea that -- any message that can possibly be accepted should be. fields :: Stream s m Char => ParsecT s u m [Field] -- | Parse a "Date:" header line and return the date it contains a -- CalendarTime. orig_date :: Stream s m Char => ParsecT s u m CalendarTime -- | Parse a "From:" header line and return the -- mailbox_list address(es) contained in it. from :: Stream s m Char => ParsecT s u m [NameAddr] -- | Parse a "Sender:" header line and return the mailbox -- address contained in it. sender :: Stream s m Char => ParsecT s u m NameAddr -- | Parse a "Reply-To:" header line and return the -- address_list address(es) contained in it. reply_to :: Stream s m Char => ParsecT s u m [NameAddr] -- | Parse a "To:" header line and return the address_list -- address(es) contained in it. to :: Stream s m Char => ParsecT s u m [NameAddr] -- | Parse a "Cc:" header line and return the address_list -- address(es) contained in it. cc :: Stream s m Char => ParsecT s u m [NameAddr] -- | Parse a "Bcc:" header line and return the address_list -- address(es) contained in it. bcc :: Stream s m Char => ParsecT s u m [NameAddr] -- | Parse a "Message-Id:" header line and return the -- msg_id contained in it. message_id :: Stream s m Char => ParsecT s u m String -- | Parse a "In-Reply-To:" header line and return the list of -- msg_ids contained in it. in_reply_to :: Stream s m Char => ParsecT s u m [String] -- | Parse a "References:" header line and return the list of -- msg_ids contained in it. references :: Stream s m Char => ParsecT s u m [String] -- | Parse a "message ID:" and return it. A message ID is almost -- identical to an angle_addr, but with stricter rules about -- folding and whitespace. msg_id :: Stream s m Char => ParsecT s u m String -- | Parse a "left ID" part of a msg_id. This is almost identical to -- the local_part of an e-mail address, but with stricter rules -- about folding and whitespace. id_left :: Stream s m Char => ParsecT s u m String -- | Parse a "right ID" part of a msg_id. This is almost identical -- to the domain of an e-mail address, but with stricter rules -- about folding and whitespace. id_right :: Stream s m Char => ParsecT s u m String -- | Parse one or more occurences of qtext or quoted_pair and -- return the concatenated string. This makes up the id_left of a -- msg_id. no_fold_quote :: Stream s m Char => ParsecT s u m String -- | Parse one or more occurences of dtext or quoted_pair and -- return the concatenated string. This makes up the id_right of a -- msg_id. no_fold_literal :: Stream s m Char => ParsecT s u m String -- | Parse a "Subject:" header line and return its contents -- verbatim. Please note that all whitespace and/or comments are -- preserved, i.e. the result of parsing "Subject: foo" is " -- foo", not "foo". subject :: Stream s m Char => ParsecT s u m String -- | Parse a "Comments:" header line and return its contents -- verbatim. Please note that all whitespace and/or comments are -- preserved, i.e. the result of parsing "Comments: foo" is -- " foo", not "foo". comments :: Stream s m Char => ParsecT s u m String -- | Parse a "Keywords:" header line and return the list of -- phrases found. Please not that each phrase is again a list of -- atoms, as returned by the phrase parser. keywords :: Stream s m Char => ParsecT s u m [[String]] -- | Parse a "Resent-Date:" header line and return the date it -- contains as CalendarTime. resent_date :: Stream s m Char => ParsecT s u m CalendarTime -- | Parse a "Resent-From:" header line and return the -- mailbox_list address(es) contained in it. resent_from :: Stream s m Char => ParsecT s u m [NameAddr] -- | Parse a "Resent-Sender:" header line and return the -- mailbox_list address(es) contained in it. resent_sender :: Stream s m Char => ParsecT s u m NameAddr -- | Parse a "Resent-To:" header line and return the -- mailbox address contained in it. resent_to :: Stream s m Char => ParsecT s u m [NameAddr] -- | Parse a "Resent-Cc:" header line and return the -- address_list address(es) contained in it. resent_cc :: Stream s m Char => ParsecT s u m [NameAddr] -- | Parse a "Resent-Bcc:" header line and return the -- address_list address(es) contained in it. (This list may be -- empty.) resent_bcc :: Stream s m Char => ParsecT s u m [NameAddr] -- | Parse a "Resent-Message-ID:" header line and return the -- msg_id contained in it. resent_msg_id :: Stream s m Char => ParsecT s u m String return_path :: Stream s m Char => ParsecT s u m String path :: Stream s m Char => ParsecT s u m String received :: Stream s m Char => ParsecT s u m ([(String, String)], CalendarTime) name_val_list :: Stream s m Char => ParsecT s u m [(String, String)] name_val_pair :: Stream s m Char => ParsecT s u m (String, String) item_name :: Stream s m Char => ParsecT s u m String item_value :: Stream s m Char => ParsecT s u m String -- | Parse an arbitrary header field and return a tuple containing the -- field_name and unstructured text of the header. The name -- will not contain the terminating colon. optional_field :: Stream s m Char => ParsecT s u m (String, String) -- | Parse and return an arbitrary header field name. That is one or more -- ftext characters. field_name :: Stream s m Char => ParsecT s u m String -- | Match and return any ASCII character except for control characters, -- whitespace, and ":". ftext :: Stream s m Char => ParsecT s u m Char -- | Match the obsolete "quoted pair" syntax, which - unlike -- quoted_pair - allowed any ASCII character to be -- specified when quoted. The parser will return both, the backslash and -- the actual character. obs_qp :: Stream s m Char => ParsecT s u m String -- | Match the obsolete "text" syntax, which - unlike text - allowed -- "carriage returns" and "linefeeds". This is really weird; you better -- consult the RFC for details. The parser will return the complete -- string, including those special characters. obs_text :: Stream s m Char => ParsecT s u m String -- | Match and return the obsolete "char" syntax, which - unlike -- character - did not allow "carriage return" and "linefeed". obs_char :: Stream s m Char => ParsecT s u m Char -- | Match and return the obsolete "utext" syntax, which is identical to -- obs_text. obs_utext :: Stream s m Char => ParsecT s u m String -- | Match the obsolete "phrase" syntax, which - unlike phrase - -- allows dots between tokens. obs_phrase :: Stream s m Char => ParsecT s u m [String] -- | Match a "phrase list" syntax and return the list of Strings -- that make up the phrase. In contrast to a phrase, the -- obs_phrase_list separates the individual words by commas. This -- syntax is - as you will have guessed - obsolete. obs_phrase_list :: Stream s m Char => ParsecT s u m [String] -- | Parse and return an "obsolete fws" token. That is at least one -- wsp character, followed by an arbitrary number (including zero) -- of crlf followed by at least one more wsp character. obs_fws :: Stream s m Char => ParsecT s u m String -- | Parse a day_name but allow for the obsolete folding syntax. obs_day_of_week :: Stream s m Char => ParsecT s u m Day -- | Parse a year but allow for a two-digit number (obsolete) and -- the obsolete folding syntax. obs_year :: Stream s m Char => ParsecT s u m Int -- | Parse a month_name but allow for the obsolete folding syntax. obs_month :: Stream s m Char => ParsecT s u m Month -- | Parse a day but allow for the obsolete folding syntax. obs_day :: Stream s m Char => ParsecT s u m Int -- | Parse a hour but allow for the obsolete folding syntax. obs_hour :: Stream s m Char => ParsecT s u m Int -- | Parse a minute but allow for the obsolete folding syntax. obs_minute :: Stream s m Char => ParsecT s u m Int -- | Parse a second but allow for the obsolete folding syntax. obs_second :: Stream s m Char => ParsecT s u m Int -- | Match the obsolete zone names and return the appropriate offset. obs_zone :: Stream s m Char => ParsecT s u m Int -- | This parser matches the "obsolete angle address" syntax, a construct -- that used to be called "route address" in earlier RFCs. It differs -- from a standard angle_addr in two ways: (1) it allows far more -- liberal insertion of folding whitespace and comments and (2) the -- address may contain a "route" (which this parser ignores): -- --
--   >>> parse obs_angle_addr "" "<@example1.org,@example2.org:joe@example.org>"
--   Right "<joe@example.org>"
--   
obs_angle_addr :: Stream s m Char => ParsecT s u m String -- | This parser parses the "route" part of obs_angle_addr and -- returns the list of Strings that make up this route. Relies on -- obs_domain_list for the actual parsing. obs_route :: Stream s m Char => ParsecT s u m [String] -- | This parser parses a list of domain names, each of them prefaced with -- an "at". Multiple names are separated by a comma. The list of -- domains is returned - and may be empty. obs_domain_list :: Stream s m Char => ParsecT s u m [String] -- | Parse the obsolete syntax of a local_part, which allowed for -- more liberal insertion of folding whitespace and comments. The actual -- string is returned. obs_local_part :: Stream s m Char => ParsecT s u m String -- | Parse the obsolete syntax of a domain, which allowed for more -- liberal insertion of folding whitespace and comments. The actual -- string is returned. obs_domain :: Stream s m Char => ParsecT s u m String -- | This parser will match the obsolete syntax for a mailbox_list. -- This one is quite weird: An obs_mbox_list contains an arbitrary -- number of mailboxes - including none -, which are separated by -- commas. But you may have multiple consecutive commas without giving a -- mailbox. You may also have a valid obs_mbox_list that -- contains no mailbox at all. On the other hand, you -- must have at least one comma. The following example is valid: -- --
--   >>> parse obs_mbox_list "" ","
--   Right []
--   
-- -- But this one is not: -- --
--   >>> parse obs_mbox_list "" "joe@example.org"
--   Left (line 1, column 16):
--   unexpected end of input
--   expecting obsolete syntax for a list of mailboxes
--   
obs_mbox_list :: Stream s m Char => ParsecT s u m [NameAddr] -- | This parser is identical to obs_mbox_list but parses a list of -- addresses rather than mailboxes. The main difference is -- that an address may contain groups. Please note that as -- of now, the parser will return a simple list of addresses; the -- grouping information is lost. obs_addr_list :: Stream s m Char => ParsecT s u m [NameAddr] obs_fields :: Stream s m Char => ParsecT s u m [Field] -- | Parse a date header line but allow for the obsolete folding -- syntax. obs_orig_date :: Stream s m Char => ParsecT s u m CalendarTime -- | Parse a from header line but allow for the obsolete folding -- syntax. obs_from :: Stream s m Char => ParsecT s u m [NameAddr] -- | Parse a sender header line but allow for the obsolete folding -- syntax. obs_sender :: Stream s m Char => ParsecT s u m NameAddr -- | Parse a reply_to header line but allow for the obsolete folding -- syntax. obs_reply_to :: Stream s m Char => ParsecT s u m [NameAddr] -- | Parse a to header line but allow for the obsolete folding -- syntax. obs_to :: Stream s m Char => ParsecT s u m [NameAddr] -- | Parse a cc header line but allow for the obsolete folding -- syntax. obs_cc :: Stream s m Char => ParsecT s u m [NameAddr] -- | Parse a bcc header line but allow for the obsolete folding -- syntax. obs_bcc :: Stream s m Char => ParsecT s u m [NameAddr] -- | Parse a message_id header line but allow for the obsolete -- folding syntax. obs_message_id :: Stream s m Char => ParsecT s u m String -- | Parse an in_reply_to header line but allow for the obsolete -- folding and the obsolete phrase syntax. obs_in_reply_to :: Stream s m Char => ParsecT s u m [String] -- | Parse a references header line but allow for the obsolete -- folding and the obsolete phrase syntax. obs_references :: Stream s m Char => ParsecT s u m [String] -- | Parses the "left part" of a message ID, but allows the obsolete -- syntax, which is identical to a local_part. obs_id_left :: Stream s m Char => ParsecT s u m String -- | Parses the "right part" of a message ID, but allows the obsolete -- syntax, which is identical to a domain. obs_id_right :: Stream s m Char => ParsecT s u m String -- | Parse a subject header line but allow for the obsolete folding -- syntax. obs_subject :: Stream s m Char => ParsecT s u m String -- | Parse a comments header line but allow for the obsolete folding -- syntax. obs_comments :: Stream s m Char => ParsecT s u m String -- | Parse a keywords header line but allow for the obsolete folding -- syntax. Also, this parser accepts obs_phrase_list. obs_keywords :: Stream s m Char => ParsecT s u m [String] -- | Parse a resent_from header line but allow for the obsolete -- folding syntax. obs_resent_from :: Stream s m Char => ParsecT s u m [NameAddr] -- | Parse a resent_sender header line but allow for the obsolete -- folding syntax. obs_resent_send :: Stream s m Char => ParsecT s u m NameAddr -- | Parse a resent_date header line but allow for the obsolete -- folding syntax. obs_resent_date :: Stream s m Char => ParsecT s u m CalendarTime -- | Parse a resent_to header line but allow for the obsolete -- folding syntax. obs_resent_to :: Stream s m Char => ParsecT s u m [NameAddr] -- | Parse a resent_cc header line but allow for the obsolete -- folding syntax. obs_resent_cc :: Stream s m Char => ParsecT s u m [NameAddr] -- | Parse a resent_bcc header line but allow for the obsolete -- folding syntax. obs_resent_bcc :: Stream s m Char => ParsecT s u m [NameAddr] -- | Parse a resent_msg_id header line but allow for the obsolete -- folding syntax. obs_resent_mid :: Stream s m Char => ParsecT s u m String -- | Parse a Resent-Reply-To header line but allow for the -- obsolete folding syntax. obs_resent_reply :: Stream s m Char => ParsecT s u m [NameAddr] obs_return :: Stream s m Char => ParsecT s u m String obs_received :: Stream s m Char => ParsecT s u m [(String, String)] -- | Match obs_angle_addr. obs_path :: Stream s m Char => ParsecT s u m String -- | This parser is identical to optional_field but allows the more -- liberal line-folding syntax between the "field_name" and the "field -- text". obs_optional :: Stream s m Char => ParsecT s u m (String, String) instance GHC.Show.Show a => GHC.Show.Show (Text.Parsec.Rfc2822.GenericMessage a) instance GHC.Show.Show Text.Parsec.Rfc2822.Field instance GHC.Classes.Eq Text.Parsec.Rfc2822.NameAddr instance GHC.Show.Show Text.Parsec.Rfc2822.NameAddr