codec-mbox-0.2.0.0: A library to read and write mailboxes in mbox format

Portability
Stabilityprovisional
MaintainerNicolas Pouillard <nicolas.pouillard@gmail.com>
Safe HaskellNone

Codec.Mbox

Contents

Description

 

Synopsis

Mailbox, message, and direction data types

newtype Mbox s Source

An Mbox is a list of MboxMessage

Constructors

Mbox 

Fields

mboxMessages :: [MboxMessage s]
 

Instances

Eq s => Eq (Mbox s) 
Ord s => Ord (Mbox s) 
Show s => Show (Mbox s) 

data MboxMessage s Source

An MboxMessage represent an mbox message, featuring the sender, the date-time, and the message body.

Instances

Eq s => Eq (MboxMessage s) 
Ord s => Ord (MboxMessage s) 
Show s => Show (MboxMessage s) 

data Direction Source

Constructors

Backward 
Forward 

Mailbox parsing functions

parseMboxFile :: Direction -> FilePath -> IO (Mbox ByteString)Source

Returns a mbox given a direction (forward/backward) and a file path.

parseMboxFiles :: Direction -> [FilePath] -> IO [Mbox ByteString]Source

Returns a mbox list given a direction (forward/backward) and a list of file path. Note that files are opened lazily.

parseMbox :: ByteString -> Mbox ByteStringSource

Turns a ByteString into an Mbox by splitting on From_ lines and unquoting the '>*From's of the message.

safeParseMbox :: FilePath -> Int64 -> ByteString -> Either String (Mbox ByteString)Source

Same as parseMbox but cat returns an error message. However only the line can cause an error message currently, so it's fine to dispatch on the either result.

parseOneMboxMessage :: FilePath -> Handle -> Integer -> IO (MboxMessage ByteString)Source

Given a file handle and an offset, parseOneMboxMessage returns the message a this offset.

Mailbox printing functions

showMboxMessage :: MboxMessage ByteString -> ByteStringSource

Returns a ByteString given an mbox message.

showMboxFromLine :: MboxMessage ByteString -> ByteStringSource

Returns an header line in mbox format given an mbox message.

First-class labels

mboxMsgSender :: Functor f => (a -> f a) -> MboxMessage a -> f (MboxMessage a)Source

Message's sender lens

mboxMsgTime :: Functor f => (a -> f a) -> MboxMessage a -> f (MboxMessage a)Source

Message's time lens

mboxMsgBody :: Functor f => (a -> f a) -> MboxMessage a -> f (MboxMessage a)Source

Message's body lens

mboxMsgFile :: Functor f => (FilePath -> f FilePath) -> MboxMessage a -> f (MboxMessage a)Source

First-class label to the file path of mbox's message

mboxMsgOffset :: Functor f => (Int64 -> f Int64) -> MboxMessage a -> f (MboxMessage a)Source

First-class label to the offset of the given message into the mbox

Misc

data Month Source

Constructors

Jan 
Feb 
Mar 
Apr 
May 
Jun 
Jul 
Aug 
Sep 
Oct 
Nov 
Dec 

Instances

fromQuoting :: (Int64 -> Int64) -> ByteString -> ByteStringSource

fromQuoting f s returns s where the quoting level of From_ lines has been updated using the f function.

The From_ spefication, quoted from http://qmail.org./man/man5/mbox.html:

   >From quoting ensures that the resulting
   lines are not From_ lines:  the program prepends a > to any
   From_ line, >From_ line, >>From_ line, >>>From_ line, etc.