]> gitweb.michael.orlitzky.com - dead/halcyon.git/blobdiff - src/Mail.hs
Add Haddock documentation for most functions and types.
[dead/halcyon.git] / src / Mail.hs
index c280f1e82d2f6324385d484b6c8570af7989e041..ba605f977673ae3a76694888131767bfd383e255 100644 (file)
@@ -1,3 +1,5 @@
+-- |Email functions and data types.
+
 module Mail
 where
 
@@ -11,6 +13,7 @@ import System.IO
 
 type Header = String
 
+-- |A crude model of an RFC821 email message.
 data Message = Message { headers :: [Header],
                          subject :: String,
                          body    :: String,
@@ -18,7 +21,10 @@ data Message = Message { headers :: [Header],
                          to      :: String }
              deriving (Eq)
 
-instance Show Message where
+-- |Showing a message will print it in roughly RFC-compliant
+-- form. This form is sufficient for handing the message off to
+-- sendmail.
+instance Show Message where    
     show m =
         concat [ if (length (headers m) == 0) then "" else (intercalate "\n" (headers m)) ++ "\n",
                  "Subject: " ++ (subject m) ++ "\n",
@@ -28,6 +34,8 @@ instance Show Message where
                  (body m) ]
 
 
+-- |Takes a message as an argument, and passes it to the system's
+-- sendmail binary.
 sendmail :: Message -> IO (String, String, ExitCode)
 sendmail message = do
   let sendmail_args = ["-f",
@@ -53,6 +61,9 @@ sendmail message = do
   return (outs, errs, ec)
 
 
+-- |The 'sendmail' function returns a three-tuple of its outputs,
+-- 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
     case ec of