htsn 0.0.11 → 0.1.0
raw patch · 2 files changed
+12/−6 lines, 2 files
Files
- htsn.cabal +1/−1
- src/Main.hs +11/−5
htsn.cabal view
@@ -1,5 +1,5 @@ name: htsn-version: 0.0.11+version: 0.1.0 cabal-version: >= 1.8 author: Michael Orlitzky maintainer: Michael Orlitzky <michael@orlitzky.com>
src/Main.hs view
@@ -5,6 +5,7 @@ where -- System imports.+import Control.Applicative ( (<$>) ) import Control.Concurrent ( threadDelay ) import Control.Exception ( bracket, throw ) import Control.Monad ( when )@@ -71,12 +72,17 @@ -- 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 @@ 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