mbox 0.2 → 0.3
raw patch · 3 files changed
+12/−11 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- Data/MBox.hs +5/−7
- Data/MBox/String.hs +2/−0
- mbox.cabal +5/−4
Data/MBox.hs view
@@ -10,6 +10,8 @@ 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.+ -} ------------------------------------------------------------------------- @@ -21,7 +23,7 @@ import System.Locale import Data.Time import Safe-import qualified Data.Text as T+import qualified Data.Text.Lazy as T type MBox = [Message] data Message = Message {fromLine :: T.Text, headers :: [Header], body :: T.Text} deriving (Read, Show)@@ -50,8 +52,8 @@ readHeaders [] = ([],[]) readHeaders (x:xs) | T.null x || T.all isSpace x || not (T.any (==':') x) = ([],xs)- | otherwise = first ((second (killSpace . sanHeader . (`T.append` headerCont) . T.drop 1) . T.break (==':') $ x):) $ readHeaders xs'- where (headerCont, xs') = first ((T.pack " " `T.append`) . T.unlines . map killSpace) . break notCont $ xs+ | otherwise = first ((second (T.strip . sanHeader . (`T.append` headerCont) . T.drop 1) . T.break (==':') $ x):) $ readHeaders xs'+ where (headerCont, xs') = first ((T.pack " " `T.append`) . T.unlines . map T.strip) . break notCont $ xs notCont :: T.Text -> Bool notCont s = doesNotStartSpace s || allSpace s allSpace = T.all isSpace@@ -69,7 +71,6 @@ sanHeader :: T.Text -> T.Text sanHeader = T.replace (T.pack "\n") (T.pack " ") - -- | Renders an MBox into Text showMBox :: MBox -> T.Text showMBox = T.concat . map showMessage@@ -84,9 +85,6 @@ | isFrom x = '>' `T.cons` x | otherwise = x isFrom x = (T.pack "From ") `T.isPrefixOf` T.dropWhile (=='>') x--killSpace :: T.Text -> T.Text-killSpace = T.strip -- | Return True if header is a Message-ID header. isID :: Header -> Bool
Data/MBox/String.hs view
@@ -9,6 +9,8 @@ Reads and writes mboxrd files as per <http://www.qmail.org/man/man5/mbox.html>. +This parser is written to be a streaming parser. Given a lazy source of data and a streaming consumer, you should be able to analyze arbitrary mbox files in constant space.+ -} -------------------------------------------------------------------------
mbox.cabal view
@@ -1,5 +1,5 @@ name: mbox-version: 0.2+version: 0.3 synopsis: Read and write standard mailbox files. description: Read and write standard mailbox (mboxrd) files. category: system, text, data@@ -7,15 +7,16 @@ license-file: LICENSE author: Gershom Bazerman maintainer: gershomb@gmail.com-Tested-With: GHC == 6.10.3+Tested-With: GHC == 7.8+ Build-Type: Simple Cabal-Version: >= 1.6 library- build-depends: base >= 4, base < 6, safe, time, old-locale, text+ build-depends: base >= 4, base < 6, safe, time < 1.5, old-locale, text exposed-modules: Data.MBox, Data.MBox.String ghc-options: -Wall source-repository head type: darcs- location: http://patch-tag.com/r/gershomb/mbox+ location: http://hub.darcs.net/gershomb/mbox