X-Git-Url: http://gitweb.michael.orlitzky.com/?p=dead%2Fhalcyon.git;a=blobdiff_plain;f=src%2FMail.hs;h=db5673f62c84bef2964e2e1cb4fb188ec3d43a49;hp=e1884afb9daf0c9fa2df33b67b30e81f82ab79a9;hb=d721869c5e7395c021cc79f40720bdb275d613d2;hpb=9b6d95a82745ced2a58d9bc4ded555ee36b36673 diff --git a/src/Mail.hs b/src/Mail.hs index e1884af..db5673f 100644 --- a/src/Mail.hs +++ b/src/Mail.hs @@ -5,6 +5,7 @@ where import Control.Concurrent import Control.Exception (evaluate) +import Control.Monad (liftM) import Data.List (intercalate) import Data.Time (formatTime, getZonedTime) import System.Exit @@ -44,7 +45,7 @@ instance Show Message where (body m) ] where formatted_headers = - if (length (headers m) == 0) + if null (headers m) then "" else (intercalate "\n" (headers m)) ++ "\n" @@ -62,9 +63,9 @@ pad_left str n -- | Constructs a 'String' in RFC822 date format for the current -- date/time. rfc822_now :: IO String -rfc822_now = do - date <- getZonedTime - return $ formatTime defaultTimeLocale rfc822DateFormat date +rfc822_now = + liftM (formatTime defaultTimeLocale rfc822DateFormat) getZonedTime + @@ -100,7 +101,7 @@ sendmail sendmail_path message = do -- errors, and exit codes. This function pretty-prints one of those -- three-tuples. print_sendmail_result :: (String, String, ExitCode) -> IO () -print_sendmail_result (outs, errs, ec) = do +print_sendmail_result (outs, errs, ec) = case ec of ExitSuccess -> return () _ -> putStrLn $ concat ["Output: " ++ outs,