]> gitweb.michael.orlitzky.com - dead/htsn.git/blobdiff - src/Main.hs
Bump version to 0.1.0.
[dead/htsn.git] / src / Main.hs
index aebf5c503aa53f413100243900aee69b939e3c99..de0e28e53ea9dfa48fa4d8cb202216b1e9b67788 100644 (file)
@@ -5,6 +5,7 @@ module Main
 where
 
 -- System imports.
+import Control.Applicative ( (<$>) )
 import Control.Concurrent ( threadDelay )
 import Control.Exception ( bracket, throw )
 import Control.Monad ( when )
@@ -71,12 +72,17 @@ recv_line h = do
 --   This can fail, but we don't purposefully throw any exceptions. If
 --   something goes wrong, we would rather log it and keep going.
 --
+--   And in fact the only \"error\" that can occur is from
+--   'parse_xmlfid' if TSN sends us a non-integer XML File ID. But
+--   this is expected from time to time, and is merely unsupported. So
+--   we report any failures as info instead of as errors.
+--
 save_document :: Configuration
               -> String -- ^ String representation of an XML document
               -> IO ()
 save_document cfg doc =
   case either_path of
-    Left err -> report_error err
+    Left err -> report_info err -- Can only be non-integer XML File ID
     Right path -> do
       already_exists <- doesFileExist path
       when already_exists $ do
@@ -85,10 +91,10 @@ save_document cfg doc =
       writeFile path doc
       report_info $ "Wrote file: " ++ path ++ "."
   where
-    -- All the fmaps are because we're working inside a Maybe.
-    xmlfid = fmap show (parse_xmlfid doc)
-    filename = fmap (++ ".xml") xmlfid
-    either_path = fmap ((output_directory cfg) </>) filename
+    -- All the <$> are because we're working inside an Either.
+    xmlfid = show <$> (parse_xmlfid doc)
+    filename = (++ ".xml") <$> xmlfid
+    either_path = ((output_directory cfg) </>) <$> filename
 
 
 -- | Loop forever, writing the @buffer@ to file whenever a