mbox-0.3.1: Read and write standard mailbox files.

Copyright | (c) Gershom Bazerman, 2009; ported to Text by Alexander Jerneck, 2012
License | BSD 3 Clause
Maintainer | gershomb@gmail.com
Stability | experimental
Safe Haskell | Safe
Language | Haskell98

Data.MBox

Description

Reads and writes mboxrd files as per http://www.qmail.org/man/man5/mbox.html.

This module uses Lazy Text pervasively, and should be able to operate as a streaming parser. That is to say, given a lazy stream of Text, and a streaming processing function, you should be able to analyze large mbox files in constant space.

Synopsis

- type MBox = [Message]
- data Message = Message {
  - fromLine :: Text
  - headers :: [Header]
  - body :: Text
  }
- type Header = (Text, Text)
- parseMBox :: Text -> MBox
- parseForward :: Message -> Message
- parseDateHeader :: Text -> Maybe UTCTime
- showMessage :: Message -> Text
- showMBox :: MBox -> Text
- getHeader :: (Header -> Bool) -> Message -> Text
- isID :: Header -> Bool
- isDate :: Header -> Bool

# Documentation

type MBox = [Message] Source

data Message Source

Constructors

Message |

Fields

fromLine :: Text
headers :: [Header]
body :: Text

Instances

Read Message Source |
Show Message Source |

type Header = (Text, Text) Source

parseMBox :: Text -> MBox Source

Parses Text as an mbox file.

parseForward :: Message -> Message Source

Attempts to retrieve the contents of a forwarded message from an enclosing message.

parseDateHeader :: Text -> Maybe UTCTime Source

Reads a date header as a UTCTime

showMessage :: Message -> Text Source

Renders an individual message into Text.

showMBox :: MBox -> Text Source

Renders an MBox into Text

getHeader :: (Header -> Bool) -> Message -> Text Source

Return the values of headers for which predicate is True

isID :: Header -> Bool Source

Return True if header is a Message-ID header.

isDate :: Header -> Bool Source

Return True if header is a Date header.