File: message-test.hs

package info (click to toggle)
haskell-hsemail 2.2.2-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 152 kB
  • sloc: haskell: 984; makefile: 2
file content (21 lines) | stat: -rw-r--r-- 522 bytes parent folder | download | duplicates (2)
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 []               = []