-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Parsing and rendering of email and MIME headers -- @package email-header @version 0.2.0 -- | Email header types. module Network.Email.Header.Types -- | A set of email headers. type Headers = [(HeaderName, HeaderField)] -- | An email header name. type HeaderName = CI ByteString -- | The email header field. type HeaderField = ByteString -- | An email address. newtype Address Address :: ByteString -> Address -- | A Mailbox receives mail. data Mailbox Mailbox :: Maybe Text -> Address -> Mailbox displayName :: Mailbox -> Maybe Text mailboxAddress :: Mailbox -> Address -- | A Recipient is used to indicate senders and recipients of -- messages. It may either be an individual Mailbox, or a named -- group of Mailboxes. data Recipient Individual :: Mailbox -> Recipient Group :: Text -> [Mailbox] -> Recipient -- | A message identifier, which has a similar format to an email address. newtype MessageID MessageID :: ByteString -> MessageID -- | A MIME type. data MimeType MimeType :: CI ByteString -> CI ByteString -> MimeType mimeType :: MimeType -> CI ByteString mimeSubtype :: MimeType -> CI ByteString -- | MIME content type parameters. type Parameters = Map (CI ByteString) ByteString instance Eq Address instance Ord Address instance Show Address instance Eq Mailbox instance Show Mailbox instance Eq Recipient instance Show Recipient instance Eq MessageID instance Ord MessageID instance Show MessageID instance Eq MimeType instance Ord MimeType instance Show MimeType -- | A layout that keeps track of line positions. module Network.Email.Header.Layout -- | An abstract type representing a lazy layout. data Layout a -- | Run a layout with an initial position. layout :: Monoid a => Int -> Layout a -> a -- | Layout an element of a given length. span :: Monoid a => Int -> a -> Layout a -- | Layout a new line and set the initial position. break :: Int -> Layout a -- | Use the current line position to produce a layout. position :: (Int -> Layout a) -> Layout a -- | Choose the first layout if the first line fits within the given -- length, and the second otherwise. nicest :: Int -> Layout a -> Layout a -> Layout a instance Monoid (Layout a) -- | Charset conversions. module Network.Email.Charset -- | A charset. Charset names are compared fuzzily e.g. UTF-8 is -- equivalent to utf8. data Charset -- | The name of a charset. charsetName :: Charset -> String -- | All canonical charset names and aliases. charsets :: Set Charset -- | Lookup a charset from a name or alias, or Nothing if no such -- charset exists. lookupCharset :: String -> Maybe Charset -- | The default charset, UTF-8. defaultCharset :: Charset -- | Convert a Unicode string into a codepage string. fromUnicode :: Charset -> Text -> ByteString -- | Convert a codepage string into a Unicode string. toUnicode :: Charset -> ByteString -> Text instance Show Charset instance Ord Charset instance Eq Charset -- | Header formatting and pretty-printing. module Network.Email.Header.Doc -- | Rendering options. data RenderOptions RenderOptions :: Int -> Int -> Charset -> Encoding -> RenderOptions -- | The maximum line width. lineWidth :: RenderOptions -> Int -- | The indent of each line, in spaces. indent :: RenderOptions -> Int -- | The charset used to encode text outside US-ASCII range. charset :: RenderOptions -> Charset -- | The header encoding used for encoded words. encoding :: RenderOptions -> Encoding -- | The encoding used for binary characters in an encoded word. data Encoding -- | Quoted-printable encoding. Spaces are represented with underscores, -- and undisplayable characters are represented as hex pairs. QP :: Encoding -- | Base 64 encoding of all characters. Base64 :: Encoding -- | Default rendering options, which uses a line width of 80, and indent -- of 2, and utf-8 quated-printable encoding. defaultRenderOptions :: RenderOptions -- | A formatted email header. data Doc -- | Render a document with the given options and initial position. render :: RenderOptions -> Int -> Doc -> Builder -- | Construct a primitive document from a layout function. The function -- takes two parameters: the rendering options, and a Bool which -- indicates whether the containing group is laid out horizontally -- instead of vertically. prim :: (RenderOptions -> Bool -> Layout Builder) -> Doc -- | Specify an alternative layout with all line breaks flattened. group :: Doc -> Doc -- | Construct a Doc from a Builder and a length. builder :: Int -> Builder -> Doc -- | Construct a Doc from a String. string :: String -> Doc -- | Construct a Doc from a ByteString. byteString :: ByteString -> Doc -- | Construct a Builder from a Text. text :: Text -> Doc -- | A space layout. space :: Layout Builder -- | A newline layout. This will emit a CRLF pair, break to a new -- line, and indent. newline :: RenderOptions -> Layout Builder -- | A line break. If undone, behaves like a space. line :: Doc -- | A line break. If undone, behaves like mempty. linebreak :: Doc -- | A space if the remaining layout fits, and a line break otherwise. softline :: Doc -- | mempty if the remaining layout fits, and a line break -- otherwise. softbreak :: Doc -- | Concatenate with a softline in between. (>) :: Doc -> Doc -> Doc -- | Separate a list with spaces if it fits. Otherwise, separate with -- lines. sep :: [Doc] -> Doc -- | punctuate p xs appends p to every element of -- xs but the last. punctuate :: Monoid a => a -> [a] -> [a] instance Eq Encoding instance Ord Encoding instance Read Encoding instance Show Encoding instance Enum Encoding instance Bounded Encoding instance Eq RenderOptions instance Show RenderOptions instance IsString Doc instance Monoid Doc -- | Header parsers. Most exported parsers (with the exception of -- fws, cfws, and unstructured) are for parsing -- structured header fields. They expect no leading space and will eat an -- trailing white space. module Network.Email.Header.Parser -- | Skip folding whitespace. fws :: Parser () -- | Skip any comments or folding whitespace. cfws :: Parser () -- | Parse a value followed by whitespace. lexeme :: Parser a -> Parser a -- | Parse a character followed by whitespace. symbol :: Char -> Parser Char -- | Parse a list of elements, separated by commas. commaSep :: Parser a -> Parser [a] -- | Parse a date and time. TODO: non-numeric timezones (such as "PDT") are -- considered equivalent to UTC time. dateTime :: Parser ZonedTime -- | Parse an email address. address :: Parser Address -- | Parse a Mailbox. mailbox :: Parser Mailbox -- | Parse a list of Mailboxes. mailboxList :: Parser [Mailbox] -- | Parse a Recipient. recipient :: Parser Recipient -- | Parse a list of Recipients. recipientList :: Parser [Recipient] -- | Parse a message identifier. messageID :: Parser MessageID -- | Parse a list of message identifiers. messageIDList :: Parser [MessageID] -- | Parse a phrase. Adjacent encoded words are concatenated. White space -- is reduced to a single space, except when quoted or part of an encoded -- word. phrase :: Parser Text -- | Parse a comma-separated list of phrases. phraseList :: Parser [Text] -- | Parse unstructured text. Adjacent encoded words are concatenated. -- White space is reduced to a single space, except when part of an -- encoded word. unstructured :: Parser Text -- | Parse the MIME version (which should be 1.0). mimeVersion :: Parser (Int, Int) -- | Parse the content type. contentType :: Parser (MimeType, Parameters) -- | Parse the content transfer encoding. contentTransferEncoding :: Parser (CI ByteString) -- | Reading common header fields. This module is intended to be imported -- qualified: -- --
-- import qualified Network.Email.Header.Read as H --module Network.Email.Header.Read -- | Lookup and parse a header with a parser. field :: HeaderName -> Parser a -> Headers -> Maybe a -- | Lookup and parse a structured header with a parser. This skips initial -- comments and folding white space, and ensures that the entire body is -- consumed by the parser. structuredField :: HeaderName -> Parser a -> Headers -> Maybe a -- | Get the value of the Date: field. date :: Headers -> Maybe ZonedTime -- | Get the value of the From: field. from :: Headers -> Maybe [Mailbox] -- | Get the value of the Sender: field. sender :: Headers -> Maybe Mailbox -- | Get the value of the Reply-To: field. replyTo :: Headers -> Maybe [Recipient] -- | Get the value of the To: field. to :: Headers -> Maybe [Recipient] -- | Get the value of the Cc: field. cc :: Headers -> Maybe [Recipient] -- | Get the value of the Bcc: field. bcc :: Headers -> Maybe (Maybe [Recipient]) -- | Get the value of the Message-ID: field. messageID :: Headers -> Maybe MessageID -- | Get the value of the In-Reply-To: field. inReplyTo :: Headers -> Maybe [MessageID] -- | Get the value of the References: field. references :: Headers -> Maybe [MessageID] -- | Get the value of the Subject: field. subject :: Headers -> Maybe Text -- | Get the value of the Comments: field. comments :: Headers -> Maybe Text -- | Get the value of the Keywords: field. keywords :: Headers -> Maybe [Text] -- | Get the value of the Resent-Date: field. resentDate :: Headers -> Maybe ZonedTime -- | Get the value of the Resent-From: field. resentFrom :: Headers -> Maybe [Mailbox] -- | Get the value of the Resent-Sender: field. resentSender :: Headers -> Maybe Mailbox -- | Get the value of the Resent-To: field. resentTo :: Headers -> Maybe [Recipient] -- | Get the value of the Resent-Cc: field. resentCc :: Headers -> Maybe [Recipient] -- | Get the value of the Resent-Bcc: field. resentBcc :: Headers -> Maybe (Maybe [Recipient]) -- | Get the value of the Resent-Message-ID: field. resentMessageID :: Headers -> Maybe MessageID -- | Get the value of the MIME-Version: field. mimeVersion :: Headers -> Maybe (Int, Int) -- | Get the value of the Content-Type: field. contentType :: Headers -> Maybe (MimeType, Parameters) -- | Get the value of the Content-Transfer-Encoding: field. contentTransferEncoding :: Headers -> Maybe (CI ByteString) -- | Get the value of the Content-ID: field. contentID :: Headers -> Maybe MessageID -- | Formatting and pretty-printing header types. module Network.Email.Header.Pretty -- | Separate a group with commas. commaSep :: (a -> Doc) -> [a] -> Doc -- | Format a date and time. dateTime :: ZonedTime -> Doc -- | Format an address. address :: Address -> Doc -- | Format a Mailbox. mailbox :: Mailbox -> Doc -- | Format a list of Mailboxes. mailboxList :: [Mailbox] -> Doc -- | Format a Recipient. recipient :: Recipient -> Doc -- | Format a list of Recipients. recipientList :: [Recipient] -> Doc -- | Format a message identifier messageID :: MessageID -> Doc -- | Format a list of message identifiers. messageIDList :: [MessageID] -> Doc -- | Format a phrase. The text is encoded as is, unless: -- --
-- import qualified Network.Email.Header.Render as R --module Network.Email.Header.Render -- | Rendering options. data RenderOptions RenderOptions :: Int -> Int -> Charset -> Encoding -> RenderOptions -- | The maximum line width. lineWidth :: RenderOptions -> Int -- | The indent of each line, in spaces. indent :: RenderOptions -> Int -- | The charset used to encode text outside US-ASCII range. charset :: RenderOptions -> Charset -- | The header encoding used for encoded words. encoding :: RenderOptions -> Encoding -- | The encoding used for binary characters in an encoded word. data Encoding -- | Quoted-printable encoding. Spaces are represented with underscores, -- and undisplayable characters are represented as hex pairs. QP :: Encoding -- | Base 64 encoding of all characters. Base64 :: Encoding -- | Default rendering options, which uses a line width of 80, and indent -- of 2, and utf-8 quated-printable encoding. defaultRenderOptions :: RenderOptions -- | A formatted email header. data Doc -- | Render a list of headers. renderHeaders :: RenderOptions -> [(HeaderName, Doc)] -> Headers -- | Create a Date: field. date :: ZonedTime -> (HeaderName, Doc) -- | Create a From: field. from :: [Mailbox] -> (HeaderName, Doc) -- | Create a Sender: field. sender :: Mailbox -> (HeaderName, Doc) -- | Create a Reply-To: field. replyTo :: [Recipient] -> (HeaderName, Doc) -- | Create a To: field. to :: [Recipient] -> (HeaderName, Doc) -- | Create a Cc: field. cc :: [Recipient] -> (HeaderName, Doc) -- | Create a Bcc: field. bcc :: Maybe [Recipient] -> (HeaderName, Doc) -- | Create a Message-ID: field. messageID :: MessageID -> (HeaderName, Doc) -- | Create a In-Reply-To: field. inReplyTo :: [MessageID] -> (HeaderName, Doc) -- | Create a References: field. references :: [MessageID] -> (HeaderName, Doc) -- | Create a Subject: field. subject :: Text -> (HeaderName, Doc) -- | Create a Comments: field. comments :: Text -> (HeaderName, Doc) -- | Create a Keywords: field. keywords :: [Text] -> (HeaderName, Doc) -- | Create a Resent-Date: field. resentDate :: ZonedTime -> (HeaderName, Doc) -- | Create a Resent-From: field. resentFrom :: [Mailbox] -> (HeaderName, Doc) -- | Create a Resent-Sender: field. resentSender :: Mailbox -> (HeaderName, Doc) -- | Create a Resent-To: field. resentTo :: [Recipient] -> (HeaderName, Doc) -- | Create a Resent-Cc: field. resentCc :: [Recipient] -> (HeaderName, Doc) -- | Create a Resent-Bcc: field. resentBcc :: Maybe [Recipient] -> (HeaderName, Doc) -- | Create a Resent-Message-ID: field. resentMessageID :: MessageID -> (HeaderName, Doc) -- | Create a MIME-Version: field. mimeVersion :: Int -> Int -> (HeaderName, Doc) -- | Create a Content-Type: field. contentType :: MimeType -> Parameters -> (HeaderName, Doc) -- | Create a Content-Transfer-Encoding: field. contentTransferEncoding :: CI ByteString -> (HeaderName, Doc) -- | Create a Content-ID: field. contentID :: MessageID -> (HeaderName, Doc)