1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
module Main (main) where
import Text.Parsec ( parse )
import Text.Parsec.Rfc2822
-- Read an Internet message from standard input, parse it,
-- and return the result.
main :: IO ()
main = do
input <- getContents
print $ parse message "<stdin>" (fixEol input)
return ()
-- Make sure all lines are terminated by CRLF.
fixEol :: String -> String
fixEol ('\r':'\n':xs) = '\r' : '\n' : fixEol xs
fixEol ('\n':xs) = '\r' : '\n' : fixEol xs
fixEol (x:xs) = x : fixEol xs
fixEol [] = []
|